스타일을 이용해서 안드로이드 테마 적용하기
작업 순서
1) res>values>style.xml 파일 생성
2) 마니페이스 파일에 theme 등록(어플리케이션 전체 반영), Activity에 theme 적용하기(특정 액티비티 반영)
1) style.xml 파일 생성
타이틀바 제거 : <item name="android:windowNoTitle">true</item>
전체화면 : <item name="windowFullscreen">true</item>
아래 스타일은 타이틀바 제거만 사용했음
--------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 기본 스타일 지정 -->
<style name="Theme">
<item name="android:windowNoTitle">true</item>
</style>
<!-- 위에 정의한 기본 스타일을 상속받는 스타일 지정 -->
<style name="Theme.noTitle" parent="Theme">
<item name="android:textColor">#01C2FE</item>
<item name="android:textSize">25sp</item>
</style>
</resources>
--------------------------
2)
- 마니페이스 파일에 theme 등록(어플리케이션 전체 반영)
타이틀바가 제거되면서 글자의 크기와 색깔을 표시할 때 테마에 지정된 값이 반영
-------------------------------
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.noTitle"
>
<activity android:name=".Test"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
-------------------------------
- Activity에 theme 적용하기(특정 액티비티에만 반영)
타이틀바가 제거되지 않으며 글자의 크기와 색깔을 표시할 때 테마에 지정된 값만 반영
--------------------------------
public class Test extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_noTitle);
setContentView(R.layout.main);
}
}
--------------------------------
작업 순서
1) res>values>style.xml 파일 생성
2) 마니페이스 파일에 theme 등록(어플리케이션 전체 반영), Activity에 theme 적용하기(특정 액티비티 반영)
1) style.xml 파일 생성
타이틀바 제거 : <item name="android:windowNoTitle">true</item>
전체화면 : <item name="windowFullscreen">true</item>
아래 스타일은 타이틀바 제거만 사용했음
--------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 기본 스타일 지정 -->
<style name="Theme">
<item name="android:windowNoTitle">true</item>
</style>
<!-- 위에 정의한 기본 스타일을 상속받는 스타일 지정 -->
<style name="Theme.noTitle" parent="Theme">
<item name="android:textColor">#01C2FE</item>
<item name="android:textSize">25sp</item>
</style>
</resources>
--------------------------
2)
- 마니페이스 파일에 theme 등록(어플리케이션 전체 반영)
타이틀바가 제거되면서 글자의 크기와 색깔을 표시할 때 테마에 지정된 값이 반영
-------------------------------
<application android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/Theme.noTitle"
>
<activity android:name=".Test"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
-------------------------------
- Activity에 theme 적용하기(특정 액티비티에만 반영)
타이틀바가 제거되지 않으며 글자의 크기와 색깔을 표시할 때 테마에 지정된 값만 반영
--------------------------------
public class Test extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_noTitle);
setContentView(R.layout.main);
}
}
--------------------------------



덧글