记Android-BottomSheetDialogFragme

2021-08-16  本文已影响0人  晖仔Milo

今天开发,ui给了一张这样的图


image.png

好家伙,分析一番,自然是用BottomSheetDialogFragment实现最为妥当。但是,在实现圆角的时候怎么都不能符合预期,最终,循着源码发现如下。


image.png

好吧,连注解都没有,总之用它就对了。
修改:
1、代码中重写

    @Override
    public int getTheme() {
        return R.style.TranslucentHalfBottomSheetFragment;
    }

2、粘贴一下我的style

    <style name="TranslucentHalfBottomSheetFragment">
        <item name="android:windowBackground">@color/transparent_half</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowCloseOnTouchOutside">true</item>
        <!-- Note that we use the base animation style here (that is no
             animations) because we really have no idea how this kind of
             activity will be used. -->
        <item name="android:windowAnimationStyle">@android:style/Animation</item>
    </style>

这样,就妥啦。

上一篇 下一篇

猜你喜欢

热点阅读