解决Android自定义标题栏充满的问题


一个接着一个的activity,写啊写,调啊调,后来,终于发觉,activity的标题栏好难看,好单调啊。咱们为了吸引用户的眼球,得搞点个性化的东西。

自定义标题栏的方法,网上一搜一大堆,我也稍微提一下,oncreate中加上如下代码就行:

  1. requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);   
  2. setContentView(view);   
  3. getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);  

这个名为title的layout是这样子的,很简单,就是一个textview,然后有个背景色:

Xml代码

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     android:background="#66cccccc"  
  7.     >  
  8. <TextView     
  9.     android:layout_width="fill_parent"    
  10.     android:layout_height="wrap_content"    
  11.     android:text="hello"  
  12.     />  
  13. </LinearLayout>  

好,运行看效果。看到了吧,发现问题了没,标题栏的背景色没有填充满是吧,这可真是杯具哟。padding、margin什么的都用上也不管用,怎么办呢。

  • 1
  • 2
  • 3
  • 下一页

相关内容