如何设置Android工具栏高度?

Ale*_*mpa 10 android android-tabhost android-actionbar android-toolbar

我想实现这个目标:

我想的是制作一个更高的自定义工具栏,并正常使用tabhost和tabpager.我已经实现了它,但是工具栏显示的是正常高度,所以它没有显示我想要的,只是顶部.这是正确的方法还是可以将TabHost设置为线性/相对布局?因为我不需要将它作为动作栏使用它.

相关守则

toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbarTitle"
    android:orientation="vertical"
    android:background="@color/black"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/AppTheme"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <ImageView
        android:id="@+id/img_logo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="55dp"
        android:scaleType="centerInside"
        android:src="@drawable/logo_home"
        />

    <TextView
        android:id="@+id/txt_version"
        android:text="@string/app_version"
        android:textColor="@color/white"
        android:layout_below="@+id/img_logo"
        android:paddingBottom="10dp"
        android:paddingTop="15dp"
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    </RelativeLayout>
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

而这个功能在Activity中:

private void setupActionBar()
    {
        ActionBar ab = getSupportActionBar();
        ab.setDisplayShowCustomEnabled(true);
        ab.setDisplayShowTitleEnabled(false);
        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(R.layout.toolbar_title, null);
        ab.setCustomView(v);
    }
Run Code Online (Sandbox Code Playgroud)

Ell*_*ltz 18

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbarTitle"
android:orientation="vertical"
android:background="@color/black"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize" //pay attention here
android:theme="@style/AppTheme"
android:layout_height="wrap_content"> //pay attention here
Run Code Online (Sandbox Code Playgroud)

你的ToolBar这是一个ViewGroup围绕它的孩子高度的意思,这意味着它只有在孩子被测量时才会得到一个固定的大小.你的最低高度大约5060 dip,那是多么低的ToolBar会.所以,如果你的孩子身高不合理,那么它仍然是合理的<= 50

给它一个首选的高度 android:layout_height="200dp"