maxkeppeler / sheets

⭐ ‎‎‎‏‏‎ ‎Offers a range of beautiful sheets (dialogs & bottom sheets) for quick use in your project. Includes many ways to customize sheets.
https://maxkeppeler.github.io/sheets/
Apache License 2.0
921 stars 77 forks source link

Cannot use textview on bottomsheet #115

Closed Nawanop-AMNB closed 1 year ago

Nawanop-AMNB commented 2 years ago

Describe the bug Error tell that it cannot inflate textview

Library Version: 2.2.8

To Reproduce Steps to reproduce the behavior:

  1. create layout xml file
  2. add textview to xml
  3. create java class and extend sheet
  4. onCreateLayoutView inflate as guide but with ViewBinding style
  5. perform show bottomsheet

Expected behavior able to inflate textview in custom sheet

Affected Device(s):

Additional context here is error log

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.th.kenya.nawanop.videomaker, PID: 6288
    android.view.InflateException: Binary XML file line #19 in com.th.kenya.nawanop.videomaker:layout/custom_base_seek_bar_bottom_sheet: Binary XML file line #19 in com.th.kenya.nawanop.videomaker:layout/custom_base_seek_bar_bottom_sheet: Error inflating class TextView
    Caused by: android.view.InflateException: Binary XML file line #19 in com.th.kenya.nawanop.videomaker:layout/custom_base_seek_bar_bottom_sheet: Error inflating class TextView
    Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 6: TypedValue{t=0x2/d=0x101009b a=1}, theme={InheritanceMap=[id=0x7f120111com.th.kenya.nawanop.videomaker:style/BottomSheet.Base.Light, id=0x7f12029bcom.th.kenya.nawanop.videomaker:style/Theme.MaterialComponents.Light.BottomSheetDialog, id=0x7f12029fcom.th.kenya.nawanop.videomaker:style/Theme.MaterialComponents.Light.Dialog, id=0x7f12006acom.th.kenya.nawanop.videomaker:style/Base.Theme.MaterialComponents.Light.Dialog, id=0x7f12009bcom.th.kenya.nawanop.videomaker:style/Base.V21.Theme.MaterialComponents.Light.Dialog, id=0x7f12008dcom.th.kenya.nawanop.videomaker:style/Base.V14.Theme.MaterialComponents.Light.Dialog, id=0x7f12008ecom.th.kenya.nawanop.videomaker:style/Base.V14.Theme.MaterialComponents.Light.Dialog.Bridge, id=0x7f120153com.th.kenya.nawanop.videomaker:style/Platform.MaterialComponents.Light.Dialog, id=0x7f120258com.th.kenya.nawanop.videomaker:style/Theme.AppCompat.Light.Dialog, id=0x7f120052com.th.kenya.nawanop.videomaker:style/Base.Theme.AppCompat.Light.Dialog, id=0x7f120097com.th.kenya.nawanop.videomaker:style/Base.V21.Theme.AppCompat.Light.Dialog, id=0x7f1200afcom.th.kenya.nawanop.videomaker:style/Base.V7.Theme.AppCompat.Light.Dialog, id=0x7f120050com.th.kenya.nawanop.videomaker:style/Base.Theme.AppCompat.Light, id=0x7f1200abcom.th.kenya.nawanop.videomaker:style/Base.V28.Theme.AppCompat.Light, id=0x7f1200a8com.th.kenya.nawanop.videomaker:style/Base.V26.Theme.AppCompat.Light, id=0x7f1200a2com.th.kenya.nawanop.videomaker:style/Base.V23.Theme.AppCompat.Light, id=0x7f1200a0com.th.kenya.nawanop.videomaker:style/Base.V22.Theme.AppCompat.Light, id=0x7f120096com.th.kenya.nawanop.videomaker:style/Base.V21.Theme.AppCompat.Light, id=0x7f1200aecom.th.kenya.nawanop.videomaker:style/Base.V7.Theme.AppCompat.Light, id=0x7f12014fcom.th.kenya.nawanop.videomaker:style/Platform.AppCompat.Light, id=0x7f12015acom.th.kenya.nawanop.videomaker:style/Platform.V25.AppCompat.Light, id=0x1030241android:style/Theme.Material.Light.NoActionBar, id=0x1030237android:style/Theme.Material.Light, id=0x103000candroid:style/Theme.Light, id=0x1030005android:style/Theme], Themes=[com.th.kenya.nawanop.videomaker:style/BottomSheet.Base.Light, forced, com.th.kenya.nawanop.videomaker:style/Theme.VideoMaker, forced, com.th.kenya.nawanop.videomaker:style/Theme.AppCompat.Empty, forced, android:style/Theme.DeviceDefault.Light.DarkActionBar, forced]}
        at android.content.res.TypedArray.getColorStateList(TypedArray.java:600)
        at android.widget.TextView.readTextAppearance(TextView.java:4129)
        at android.widget.TextView.<init>(TextView.java:1128)
        at android.widget.TextView.<init>(TextView.java:1066)
        at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:108)
        at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:93)
        at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:88)
        at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:83)
        at com.google.android.material.theme.MaterialComponentsViewInflater.createTextView(MaterialComponentsViewInflater.java:61)
        at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:121)
        at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1565)
        at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1616)
E/AndroidRuntime:     at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:244)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1065)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
        at com.th.kenya.nawanop.videomaker.databinding.CustomBaseSeekBarBottomSheetBinding.inflate(CustomBaseSeekBarBottomSheetBinding.java:50)
        at com.th.kenya.nawanop.videomaker.databinding.CustomBaseSeekBarBottomSheetBinding.inflate(CustomBaseSeekBarBottomSheetBinding.java:44)
        at com.th.kenya.nawanop.videomaker.sheets.SeekBarBottomSheet.onCreateLayoutView(SeekBarBottomSheet.java:44)
        at com.maxkeppeler.sheets.core.Sheet.onCreateView(Sheet.kt:419)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2963)
        at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java:489)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:518)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7892)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Nawanop-AMNB commented 2 years ago

Addition Detail: I do workaround by custom TextAppearance style workaround ref: https://stackoverflow.com/questions/41727729/fatal-exception-java-lang-unsupportedoperationexception-failed-to-resolve-attr

styles.xml

    <style name="BottomSheetTextView" parent="@android:style/TextAppearance">
        <item name="android:textColorLink">@color/primary_color</item>
        <item name="android:textColorHighlight">@color/primary_color</item>
        <item name="android:textColorHint">@color/secondary_color</item>
    </style>

some_inflated_layout.xml

<!-- add theme with workaround style -->
    <TextView
        android:id="@+id/aboutName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="About"
        android:textColor="@color/white"
        android:textSize="24sp"
        android:textStyle="bold"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:theme="@style/BottomSheetTextView"
        />
ghost commented 2 years ago

Steel here

vin., 1 iul. 2022, 23:09 Nawanop-AMNB @.***> a scris:

Addition Detail: I do workaround by custom TextAppearance style workaround ref: https://stackoverflow.com/questions/41727729/fatal-exception-java-lang-unsupportedoperationexception-failed-to-resolve-attr

styles.xml

<style name="BottomSheetTextView" ***@***.***:style/TextAppearance">
    <item ***@***.***/primary_color</item>
    <item ***@***.***/primary_color</item>
    <item ***@***.***/secondary_color</item>
</style>

some_inflated_layout.xml

<TextView
    android:id="@+id/aboutName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="About"
    ***@***.***/white"
    android:textSize="24sp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    ***@***.***/BottomSheetTextView"
    />

— Reply to this email directly, view it on GitHub https://github.com/maxkeppeler/sheets/issues/115#issuecomment-1172715130, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATJ6BRVX6WNOXOAIMEOFNW3VR5NBTANCNFSM52NXPMWQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

maxkeppeler commented 1 year ago

I can not replicate this issue with the steps. It shows the added TextView in custom sheet sample without an issue. What did you mean with "inflate as guide but with ViewBinding style"?