我的 BottomSheetDialogFragment 需要圆角,因此我应用了自定义可绘制对象作为其背景。但是在应用自定义背景后,BottomSheet 上的按钮不接受自定义背景。它只显示白色背景。backgroundTint 可以正常工作并更改按钮的颜色。
主题.xml:
<style name="AppBottomSheetDialogTheme"
parent="Theme.Design.Light.BottomSheetDialog">
<item name="bottomSheetStyle">@style/AppModalStyle</item>
</style>
<style name="AppModalStyle"
parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/add_new_bg</item>
</style>
add_new_bg.xml :
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/background"/>
<corners
android:topLeftRadius="40dp"
android:topRightRadius="40dp"/>
</shape>
BottomSheetDialogFragment 代码:
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NORMAL, R.style.AppBottomSheetDialogTheme);
}