[AndroidStudio][sleeper] HomeActivity 만들기 - 1

Intelli·2022년 11월 24일
0

🌴 1. 타이틀바 없애기

  1. 아래의 코드를 theme.xml 파일의 <style> 태그 안에 작성한다.
	<item name="windowActionBar">false</item>
	<item name="windowNoTitle">true</item>
  • windowActionBar : 해당 화면이 타이틀바 위치에 액션바가 필요한지 나타내는 flag이다. Boolean값을 가진다.
  • windowNoTitle : 타이틀이 창이 없어야 하는지를 나타내는 flag이다. Boolean값을 가진다.

  1. onCreate() 함수의 super.onCreate(savedInstanceState) 아래에 다음과 같이 작성한다.
	requestWindowFeature(Window.FEATURE_NO_TITLE);
  • window.FEATURE_NO_TITLE : 스크린 위의 타이틀을 끄기 위해 필요한 flag이다.

🌵 2. 상태바 없애기

  1. 다음 두 개의 코드를 theme.xml 파일의 <style> 태그 안에 작성한다.
	<item name="android:windowTranslucentStatus">true</item>
	<item name="android:windowTranslucentNavigation">true</item>
  • windowTranslucentStatus : 반투명한 상태바를 요청할지 여부를 나타낸다.
  • windowTranslucentNavigation : 반투명한 네비게이션바를 요청할지 여부를 나타낸다.

  1. 부모 레이아웃 안에 다음과 같이 작성한다.
	android:fitsSystemWindows="true"
  • fitsfileSystemWindows : 윈도우에 맞게 뷰 레이아웃을 조정하기 위해서 사용되는 속성이다. true로 설정했을 때 뷰 패딩이 시스템 윈도우 밖으로 벗어나게 한다.
  1. 액티비티 파일 안에 다음과 같이 작성한다.
	val window = window
	window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
  • FLAG_LAYOUT_NO_LIMITS : 윈도우가 스크린 밖을 벗어나도록 한다.

이 글은 아래의 글과 안드로이드 스튜디오 공식 문서를 참조하여 작성되었습니다.

  1. 안드로이드 앱에서 타이틀바 없애기
  2. 투명한 Status Bar를 만들고 싶다면?
profile
I never dreamed about success. I worked for it.

0개의 댓글