我有一个自定义视图
<com.google.android.libraries.onegoogle.account.disc.AccountParticleDisc
android:id="@+id/account_avatar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="?attr/disc_padding"
android:contentDescription="@null"
app:imageViewSize="?attr/disc_imageViewSize"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/quantum_ic_account_circle_googblue_24"/>
及其Java:
public AccountParticleDisc(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.account_particle_disc, this, true);
this.imageView = findViewById(R.id.og_apd_internal_image_view);
badgeWrapper = findViewById(R.id.badge_wrapper);
TypedArray style = context.obtainStyledAttributes(attrs, R.styleable.AccountParticleDisc);
int discSize;
int imageViewSize;
try {
avatarSize =
style.getDimensionPixelSize(R.styleable.AccountParticleDisc_avatarSize, SIZE_NOT_SET);
discSize =
style.getDimensionPixelSize(R.styleable.AccountParticleDisc_discSize, SIZE_NOT_SET);
imageViewSize =
style.getDimensionPixelSize(R.styleable.AccountParticleDisc_imageViewSize, SIZE_NOT_SET);
} finally {
style.recycle();
}
以及这些自定义属性:
<resources>
<declare-styleable name="AccountParticle">
<attr name="disc_padding" format="reference"/>
<attr name="disc_imageViewSize" format="reference"/>
</declare-styleable>
</resources>
和
<style name="Theme.ap.header" parent="Theme.AppCompat">
<item name="text_marginStart">@dimen/account_menu_header_signed_in_avatar_margin_start</item>
<item name="text_marginEnd"> @dimen/account_menu_header_signed_in_margin_end</item>
<item name="text_marginLeft"> @dimen/account_menu_header_signed_in_avatar_margin_start</item>
<item name="text_marginRight">@dimen/account_menu_header_signed_in_margin_end</item>
<item name="disc_imageViewSize"> @dimen/account_menu_header_signed_in_disc_size</item>
<item name="disc_padding"> @dimen/account_menu_header_signed_in_avatar_margin_end</item>
</style>
我夸大了它的viewGroup:
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context,
R.style.Theme_ap_header);
LayoutInflater.from(contextThemeWrapper).inflate(R.layout.account_particle, this, true);
我收到此错误:
cause = {InflateException@12215} "android.view.InflateException: Binary XML file line #7: Error inflating class <unknown>"
detailMessage = "Binary XML file line #7: Binary XML file line #7: Error inflating class <unknown>"
我怎样才能使错误更具指示性?