Android sets the height of custom title bar

I created a regular header line. In the title bar are two images with each other and one text image below it. It works great, but I just see the top of the text. Therefore, I think the title of the header is trimmed from the bottom. Does anyone know how to set the height of a custom title bar? EDIT: My custom header line:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="45dip" android:orientation="vertical" android:id="@+id/header_root"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/header_image" android:layout_width="wrap_content" android:layout_height="27dip" android:src="@drawable/header_image" /> <ImageView android:id="@+id/options" android:layout_width="wrap_content" android:layout_height="27dip" android:layout_margin="-8dip" android:layout_toRightOf="@+id/header_image" android:src="@drawable/options" /> </RelativeLayout> <TextView android:text="Vissenencyclopedie" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:textSize="15dp" android:id="@+id/titel" android:layout_marginTop="-7dip" /> </LinearLayout> 
+4
source share
3 answers

Use style:

  <style name="CustomTheme" parent="@android:style/Theme.Light"> <item name="android:windowTitleSize">30dp</item> </style> 

And add to the manifest:

  <activity android:name=".MainActivity" android:theme="@style/CastomTheme" > </activity> 
+7
source

I assume the title bar is in some kind of layout, so you can set the height of the layout, for example:

 android:height="30dp" 

You can also specify indents for text views, for example:

 android:paddingBottom="10dp" 

This should make sure the text is displayed. Hope this helps.

+1
source

I assume the problem is android:layout_height="45dip" , which you specified for your external LinearLayout. Replace this line with android:layout_height="wrap_content" and I suppose this will solve your problem.

0
source

Source: https://habr.com/ru/post/1415746/


All Articles