본문 바로가기
Android/가끔식 필요한 코드들

[Android] Background를 투명하게 하려면.(BottomSheetDialogFragment)

by Taehyung Kim, dev 2021. 3. 2.
728x90
 class TransparentClass : BottomSheetDialogFragment() {
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setStyle( // Background -> Transparent.
            STYLE_NORMAL,
            R.style.TransparentBottomSheetDialogFragment
        )

    }
    
}

style.xml

    <style name="TransparentBottomSheetDialogFragment" parent="Theme.Design.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/TransparentBottomSheetDialogFragmentChild</item>
    </style>

    <style name="TransparentBottomSheetDialogFragmentChild" parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">#00000000</item>
    </style>

 

style.xml 에 위와같이 style 설정을 해주고

 

onCreate()에 setStyle 설정을 해준다.

 

위 예제에서는 BottomSheetDialog의 경우이다.

728x90

댓글