본문 바로가기
개발/Android Error

[Error] Toolbar나 Header가 StatusBar와 겹치는 문제

by JhDroid 2021. 1. 5.
728x90

문제

  • NavagationView의 Header에 설정한 Layout이 시스템 상태바(StatusBar)에 가려지는 문제를 확인
  • Toolbar 설정 시에도 동일한 문제가 발생할 수 있음

NavigationView HeaderLayout 상단에 나가기 버튼 추가
나가기 버튼이 시스템 상태바에 가려져 보이지 않는다.

 

해결

  • Header에 사용할 Layout에 fitsSystemWindows 속성을 설정
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="@dimen/nav_header_height"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:fitsSystemWindows="true">
		
		...
</androidx.constraintlayout.widget.ConstraintLayout>
  • fitsSystemWindows 속성은 View가 차지할 수 있는 영역을 상태바나 소프트키 영역을 제외한 영역까지 확장해주는 역할을 함

fitsSystemWindows 속성을 추가 후 나가기 버튼이 보인다.

 

 

* 글에 틀린 부분이 있으면 댓글 부탁드립니다 :D

728x90