BottomSheetDialogFragment 모서리 둥글게

By | 2021년 10월 28일
Table of Contents

BottomSheetDialogFragment 모서리 둥글게

참조

아래의 코드를 추가해 주면 BottomSheetDialog 의 모서리 부분이 둥굴게 할 수 있다.

rounded_dialog.xml

<?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>

styles.xml

아래 설정으로 모든 BottomSheetDialogFragment 의 모서리가 둥글게 설정된다.

<item name="android:windowIsFloating">false</item> 를 추가하면 네비게이션바를 덮지 않는다.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ......
    <item name="bottomSheetDialogTheme">@style/AppBottomSheetDialogTheme</item>
</style>

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

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

이미지

답글 남기기