WEB开发网
开发学院手机开发Android 开发 Android 自定义Activity的标题栏 阅读

Android 自定义Activity的标题栏

 2010-11-05 00:57:33 来源:WEB开发网   
核心提示:MyActivity.javarequestWindowFeature(Window.FEATURE_CUSTOM_TITLE);setContentView(R.layout.main);getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.t

MyActivity.java

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

setContentView(R.layout.main);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);

TextView titleTV = (TextView)findViewById(R.id.title); titleTV.setText(R.string.app_name);

title.xml

< ?xml version="1.0" encoding="UTF-8"?>

< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="horizontal"

android:layout_width="fill_parent"

android:layout_height="fill_parent" >

< TextView

android:id="@+id/title"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:layout_gravity="center"

android:gravity="center" />

< /LinearLayout>

Tags:Android 定义 Activity

编辑录入:coldstar [复制链接] [打 印]
赞助商链接