Vah*_*iri 7 android bottom-sheet
我正在使用BottomSheetDialogFragment,我正在绕着右上/左上角,它正常工作但我注意到在圆角后面,它不透明,而且非常烦人.
它在下面的截图中很明显:
我如何让它们透明?
小智 20
创建如下自定义样式。
<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/rounded_corner_top_only</item>
</style>
Run Code Online (Sandbox Code Playgroud)
然后在自定义片段中覆盖此方法。
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//bottom sheet round corners can be obtained but the while background appears to remove that we need to add this.
setStyle(DialogFragment.STYLE_NO_FRAME,R.style.AppBottomSheetDialogTheme);
}
Run Code Online (Sandbox Code Playgroud)
这对我有用,希望它对你有用。
小智 1
您必须更改bottom sheet theme才能实现顶部圆形布局
创建自定义可绘制的background_bottom_sheet_dialog_fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:topLeftRadius="8dp"
android:topRightRadius="8dp" />
<padding android:top="0dp" />
<solid android:color="@color/white" />
</shape>
Run Code Online (Sandbox Code Playgroud)
然后使用drawable作为背景覆盖styles.xml上的bottomSheetDialogTheme:
<!--Bottom sheet-->
<style name="BottomSheet" parent="@style/Widget.Design.BottomSheet.Modal">
<item
name="android:background">@drawable/background_bottom_sheet_dialog_fragment
</item>
</style>
<style name="BaseBottomSheetDialog"
parent="@style/Theme.Design.Light.BottomSheetDialog">
<item name="android:windowIsFloating">false</item>
<item name="bottomSheetStyle">@style/BottomSheet</item>
</style>
<style name="BottomSheetDialogTheme" parent="BaseBottomSheetDialog" />
Run Code Online (Sandbox Code Playgroud)
这将更改底部工作表的背景布局
注意:从底部工作表对话框视图布局中删除所有背景
| 归档时间: |
|
| 查看次数: |
1018 次 |
| 最近记录: |