Android - 自定义标题栏

标签 android android-layout android-titlebar

我想为 Android 应用程序自定义标题栏。我有以下布局:

<?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:layout_height="fill_parent"/>

</LinearLayout>

我在目标 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);
        ... 
}

我不明白为什么在更改 android:layout_height 值时标题栏的高度不会改变。

我错过了什么吗?

谢谢!

最佳答案

根据 this article ,您应该为此创建一个自定义样式。看看它是否适合您。

关于Android - 自定义标题栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6202748/

相关文章:

java - Bauerca drag-sort-listview 简单示例

android - FloatingActionButton 被 Fragment 中的 ListView 覆盖

android - 将新项目计数添加到按钮上的图标 - Android

android - 如何强制 Android 应用程序重新加载与语言更改对应的 Activity 标题?

Android - 在 Activity 的 onCreate() 中调用 setTitle() 时如何避免延迟

android - Android中的USB type-c耳机检测

android - 如何在 Android 中使用 JSON 从 MySQL 检索图像?

java - 更改 fragment 更改主题

android - 下面带有 MPAndroidChart(或其他)的 ListView

android - 为什么我会得到这种高度值差异?