페이지

2011년 5월 23일 월요일

타이틀바를 내맘대로 - CustomTitle

액티비티 화면 상단에 나타나는 타이틀 바를 내맘대로 바꿀수 있다.

코드는 생각보다 간단하다.

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);        setContentView(R.layout.custom_title);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);

R.layout.custom_title_1.xml  파일에 타이틀 바에서 보여주고 싶은 것을 구성한다.

아래는 TextView 2개를 타이틀바 왼쪽과 오른쪽에 배치한 레이아웃이다.


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen"
    android:layout_width="match_parent" android:layout_height="match_parent"
    android:orientation="vertical">
    <TextView android:id="@+id/left_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="@string/custom_title_left" />
    <TextView android:id="@+id/right_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="@string/custom_title_right" />
</RelativeLayout>

댓글 없음:

댓글 쓰기