【发布时间】:2011-11-02 18:01:20
【问题描述】:
我正在使用以下 xml 文件制作自定义标题栏:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myTitle"
android:text="custom title bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background" />
在我的活动的 onCreate() 中,我有以下代码:
public class CustomTitleBar extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.mytitle);
}
}
标题栏来了没问题。我设置为背景的图像(图像的名称也是背景,你可以在上面的xml中看到)也来了。但问题出在左右两侧图像还有一点间隙,即图像没有覆盖父项的整个宽度,尽管 layout_width 已设置为“fill_parent”。
任何想法。请帮助。
【问题讨论】: