tt_mc

导航

自定义Activity的标题栏

MyActivity.java 
Java代码 复制代码
  1. requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);     
  2. setContentView(R.layout.main);            
  3. getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);     
  4. TextView titleTV = (TextView)findViewById(R.id.title);     
  5. titleTV.setText(R.string.app_name);   

title.xml
Java代码 复制代码
  1. <?xml version="1.0" encoding="UTF-8"?>   
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"        
  3. android:orientation="horizontal"       
  4. android:layout_width="fill_parent"        
  5. android:layout_height="fill_parent"     >       
  6. <TextView            
  7. android:id="@+id/title"            
  8. android:layout_width="wrap_content"            
  9. android:layout_height="wrap_content"            
  10. android:layout_weight="1"            
  11. android:layout_gravity="center"            
  12. android:gravity="center" />   
  13. </LinearLayout>  

posted on 2010-04-10 15:23  tt_mc  阅读(373)  评论(0编辑  收藏  举报