Android自定義標題欄運用

————-.java
super.onCreate(savedInstanceState);
  requestWindowFeature

(Window.FEATURE_CUSTOM_TITLE);

  setContentView(R.layout.main);

  getWindow().setFeatureInt

(Window.FEATURE_CUSTOM_TITLE,
    R.layout.main_titlebar);

————.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

xmlns:android="www.aiwalls.com"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/main_title"
        android:layout_width="160.0dip"
        android:layout_height="48.0dip"
        android:layout_gravity="center_horizontal"
        android:gravity="center_horizontal"
        android:paddingTop="10.0dip"
        android:text="@string/app_name"
        android:textColor="@color/white"
        android:textSize="20.0dip" />

</LinearLayout>

——————Manifest.xml
 <activity
            android:name=".Start"
            android:theme="@style/titlebarstyle" >
        </activity>

 

作者:gongzibai

發佈留言