material-components / material-components/material-components-android

MaterialButton android:foreground doesn't work on BottomSheetDialogFragment

Open
#2,999 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Widget: BottomSheet Widget: Button
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

Screenshot 2022-09-27 at 17 52 28

material button inside of BottomSheetDialogFragment.

Screenshot 2022-09-27 at 17 52 44

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.