开发者

Android - Customizing the title bar

I want to customize the title bar for an Android application. I have the following layout:

<?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="80dp" <!-- Problem here -->
    android:gravity="center_vertical"
    >

    <ImageView
        android:id="@+id/header"
        android:background="@drawable/windowtitle"
        android:layout_width="fill_parent"
        android:layo开发者_JAVA技巧ut_height="fill_parent"/>

</LinearLayout>

I also have a the following code in the targeted activity:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.home);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
        ... 
}

I don't understand why the height of the title bar doesn't change when changing the android:layout_height value.

Did I miss something?

Thanks!


According to this article, you should create a custom style for this. See if it works for you.


set the layout_height as wrap_content or fill_parent of the linear layout

and then try it


you can use :

getWindow().setLayout(50, 50);

of course this code use to set width and hiegth of window

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜