본문 바로가기
[programming]/[Android] 안드로이드

[Android Studio] 안드로이드 스튜디오 타이틀 바 삭제하기 title 바 지우기 타이틀 바 소스 코드 예제

by codeomni 2019. 9. 10.
반응형

 

안녕하세요.

 

이번 포스팅은 안드로이드 스튜디오에서 타이틀 바를 지우기입니다.

안드로이드 스튜디오에서 타이틀 바를 기본적으로 지원합니다.

버전에 따라서 조금 상이합니다.

 

 

 

1
2
3
4
<style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
</style>

 values에 styles.xml에 들어가면 "AppTheme.NoActionBar"가 있습니다. 없을 경우 추가합니다.

 

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
</application>

 다음으로 AndroidManifest.xml에 들어가서 Theme의 속성을 변경합니다.

 Theme의 속성으로는 "@style/AppTheme.NoActionBar"을 적용합니다.

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:theme="@style/AppTheme.AppBarOverlay">
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

 타이블 바의 적용은 activity_main에서 합니다.

 layout 형태로 적용되기 때문에 activity_main 에서 해당 레이아웃를 지우면 타이틀 바가 지워집니다.

 

 

 

 

 적용하여 실행한 화면입니다.

 layout에 따라 다르게 적용할 수 있습니다.

 

 

댓글