2. NoTitleBar 테마 적용 후 title레이아웃 정의 후 배치
(AndroidManfest.xml)
<activity android:name="Settings"
android:label="@string/sync_settings"
android:theme="@android:style/Theme.NoTitleBar"/>
(screen_sample.xml)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
정의한 title을 레이아웃에 include해준다.
2011년 4월 16일 토요일
Custom title bar 만들기 1
1.테마 적용하는 방법
(styles.xml)
<resources>
<style name="CustomTitleTheme" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>
</style>
<style name="WindowTitleBackground" parent="android:WindowTitleBackground">
<item name="android:background">@android:color/transparent</item>
</style>
</resources>
타이틀바 높이를 50dip로 배경은 투명하게 스타일 정의
(AndroidManfest.xml)
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@style/CustomTitleTheme">
안드로이드 매니페스트에 정의한 테마적용
public class CustomTitle extends Activity {
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView(int)} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.custom_title);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
.......
}
}
액티비티에 커스텀 타이틀 레이아웃을 적용하면 끝
(styles.xml)
<resources>
<style name="CustomTitleTheme" parent="android:Theme">
<item name="android:windowTitleSize">50dip</item>
<item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground</item>
</style>
<style name="WindowTitleBackground" parent="android:WindowTitleBackground">
<item name="android:background">@android:color/transparent</item>
</style>
</resources>
타이틀바 높이를 50dip로 배경은 투명하게 스타일 정의
(AndroidManfest.xml)
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:theme="@style/CustomTitleTheme">
안드로이드 매니페스트에 정의한 테마적용
public class CustomTitle extends Activity {
/**
* Initialization of the Activity after it is first created. Must at least
* call {@link android.app.Activity#setContentView(int)} to
* describe what is to be displayed in the screen.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.custom_title);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
.......
}
}
액티비티에 커스텀 타이틀 레이아웃을 적용하면 끝
피드 구독하기:
글 (Atom)