material-components / material-components/material-components-android
MaterialButton android:foreground doesn't work on BottomSheetDialogFragment
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Description:
MaterialButton android:foreground attribute doesn't work inside of a BottomSheetDialogFragment. But It works as expected in Fragment.
Expected behavior:
The foreground of MaterialButton should be shown inside of the BottomSheetDialogFragment.
material button inside of the Fragment

material button inside of BottomSheetDialogFragment.

Source code: The code snippet which is causing this issue
<com.google.android.material.button.MaterialButton
android:id="@+id/editButton"
style="@style/AppTheme.Button.BottomActionButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/d1"
android:foreground="@drawable/ic_arrow_drop_down_24dp"
android:gravity="center_vertical|center_horizontal"
android:text="@string/close_app"
android:textColor="@color/white" />
Minimal sample app repro:
Android API version: Android API version here
Material Library version: 1.5.0, 1.8.0-alpha01
Device: Emulator API 31
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided MaterialButton XML snippet and reproduce it in a BottomSheetDialogFragment, then compare the same button in a Fragment on Android API 31. Investigate how the foreground is handled in each context using Material Library 1.5.0 or 1.8.0-alpha01. Done means the foreground drawable is visibly shown in the bottom sheet as it is in the Fragment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100