I have a customView
<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"/>
and its 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();
}
and these custom attributes:
<resources>
<declare-styleable name="AccountParticle">
<attr name="disc_padding" format="reference"/>
<attr name="disc_imageViewSize" format="reference"/>
</declare-styleable>
</resources>
with
<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>
I inflate its viewGroup:
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context,
R.style.Theme_ap_header);
LayoutInflater.from(contextThemeWrapper).inflate(R.layout.account_particle, this, true);
I get this error:
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>"
how can i make the error more indicative?
I suspect that the package name for custom view is invalid.
If your package name is
com.example.app
& yourCustomView
is in the same package then you should use -