본문 바로가기

Android

[안드로이드]타이틀바, 액션바 커스터마이징(full screen)

안드로이드 액션바와 상태바는 다음과 같이 구성되어 있다.






상태바와 액션바는 메니페스트와 소스상에서 수정할 수 있다.


1. 소스상에서 없애기

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//상태바 없애기
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//타이틀바 없애기
requestWindowFeature(Window.FEATURE_NO_TITLE);
     //상태바 & 타이틀바 없애기
setTheme(android.R.style.Theme_NoTitleBar_Fullscreen);
setContentView(R.layout.activity_main);
}
}

세개중에서 필요한것을 사용



2. 메니페스트에서 없애기

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.softheaven.firstproject">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:theme="@style/Theme.First">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

중간부분에 android:theme="@style/Theme.First"

를 삽입하여 해당 Activity에 스타일을 적용시킨다.


Theme.First는 res/value/styles.xml 파일에서 원하는대로 커스트마이징한 것으로 

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="Theme.First" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@color/colorBlack</item>
<item name="android:windowFullscreen">true</item>
</style>

</resources>

이런식으로 Custom Style을 작성하여 각각의 Activity에 적용시켜주면 된다.

'Android' 카테고리의 다른 글

[안드로이드]merge태그  (0) 2016.09.20
[안드로이드]ndk란?  (0) 2016.08.11
[안드로이드]Media  (0) 2016.07.20
[안드로이드] NFC사용하기  (0) 2016.07.20
[안드로이드]GCM이란? node.js로 푸시알람 구현하기  (0) 2016.06.25