Android BottomSheetDialog解除背景发暗(想设置圆角但是失败)

主要通过styles.xml设置样式来实现。
下面是styles.xml的部分:

<style name="AppBottomSheetDialogTheme"
        parent="Theme.Design.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/AppModalStyle</item>
        <item name="android:backgroundDimEnabled">false</item>
    </style>

    <style name="AppModalStyle"
        parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@drawable/shape_sheet_dialog_bg</item>
    </style>

通过将android:backgroundDimEnabled(dim是昏暗的意思)(总的意思就是背景是否设置为昏暗模式),默认是true,现在我们设为false

本来想通过更改android:background属性来实现圆角矩形的。
@drawable/shape_sheet_dialog_bg的内容是:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@android:color/white"/>
    <corners android:topLeftRadius="16dp"
        android:topRightRadius="16dp"/>
</shape>

效果如下图:
圆角BottomSheetDialog
java代码创建BottomSheetDialog时,指定此时的style。如下:

final BottomSheetDialog bottomSheetDialog = new 
		BottomSheetDialog(this,R.style.AppBottomSheetDialogTheme);

实现的效果变化如下图:
之前:
在这里插入图片描述
之后:
在这里插入图片描述
但是圆角的效果并没有实现,欢迎大神在评论区解答我的疑惑,为啥圆角的效果没有实现。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值