当前位置:操作系统 > 安卓/Android >>

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.zzzyk.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
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,