解决Android自定义标题栏充满的问题
解决Android自定义标题栏充满的问题
一个接着一个的activity,写啊写,调啊调,后来,终于发觉,activity的标题栏好难看,好单调啊。咱们为了吸引用户的眼球,得搞点个性化的东西。
自定义标题栏的方法,网上一搜一大堆,我也稍微提一下,oncreate中加上如下代码就行:
- requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
- setContentView(view);
- getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);
这个名为title的layout是这样子的,很简单,就是一个textview,然后有个背景色:
Xml代码
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#66cccccc"
- >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="hello"
- />
- </LinearLayout>
好,运行看效果。看到了吧,发现问题了没,标题栏的背景色没有填充满是吧,这可真是杯具哟。padding、margin什么的都用上也不管用,怎么办呢。
|
评论暂时关闭