안드로이드 bottom sheet에서 키보드 조정하기

Yodi.Song·2021년 7월 22일
0

안드로이드

목록 보기
5/5

수정 전

수정

  1. styles.xml의 CustomBottomSheetDialogTheme 수정

        <?xml version="1.0" encoding="utf-8"?>
        <resources xmlns:tools="http://schemas.android.com/tools">
    
            <style name="CustomBottomSheetDialogTheme" parent="Theme.MaterialComponents.Light.BottomSheetDialog">
                <item name="bottomSheetStyle">@style/CustomBottomSheetStyle</item>
                <item name="android:windowIsFloating">false</item>
                <item name="android:statusBarColor" tools:targetApi="lollipop">@android:color/transparent</item>
                <item name="android:windowSoftInputMode">adjustResize</item>
    
              
  1. themes.xml 수정

    <style name="Base.Theme.Pomodoro" parent="Theme.MaterialComponents.DayNight.NoActionBar">
           ...
    
            <item name="bottomSheetDialogTheme">@style/CustomBottomSheetDialogTheme</item>
        </style>

    앱 기본 테마에 1번에서 수정한 bottomSheetDialogTheme을 추가합니다.

3. BottomSheetDialogFragment() 에 위에서 설정한 style 추가
class TagPickerDialog: BottomSheetDialogFragment() {

    ...
   
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NORMAL, R.style.CustomBottomSheetDialogTheme)

    }
    
    ...

수정 후


참고한 자료

0개의 댓글