How to set android toolbar height?

I want to achieve this:

I decided to create a custom toolbar with a higher height and work with tabhost and tabpager in normal mode. I implemented it, but the toolbar shows the normal height, so it does not appear the way I want, only the top. Is this the right approach, or can TabHost be set below the linear / relative layout? Because I do not need to work with it as an action bar.

Corresponding code

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> 

And this function in 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); } 
+7
android android-actionbar android-tabhost android-toolbar
source share
2 answers
 <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 

your ToolBar , which is a ViewGroup , is swinging its height around its children, which means that it will get a fixed size only if the children are measured. your minimum height is between 50 and 60 dip , so it will be lower than your ToolBar . therefore, if your childrenโ€™s height is not large enough, it will be <= 50

give it your preferred android:layout_height="200dp" height android:layout_height="200dp"

+11
source share

Use some theme without an action bar for this action or the entire application if you do not need the functionality of an action bar (for example, Theme.Holo.NoActionBar ). You can add a top bar layout directly in the root activity layout. If you will use it in other actions, consider creating separate xml files for the layout or even your own ActionBarView class.

0
source share

All Articles