Android设置自定义标题栏的高度
我做了一个自定义标题栏。标题栏中有两个相邻的图像视图和一个下方的文本视图。它工作正常,但我只看到文本视图的顶部。因此,我认为标题栏的底部被裁剪了。有人知道如何设置自定义标题栏的高度吗? 编辑:我的自定义标题栏:Android设置自定义标题栏的高度,android,height,titlebar,Android,Height,Titlebar,我做了一个自定义标题栏。标题栏中有两个相邻的图像视图和一个下方的文本视图。它工作正常,但我只看到文本视图的顶部。因此,我认为标题栏的底部被裁剪了。有人知道如何设置自定义标题栏的高度吗? 编辑:我的自定义标题栏: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_
<?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>
我假设标题栏位于某种布局内,因此您可以设置布局的高度,例如:
android:height="30dp"
android:paddingBottom="10dp"
您还可以为文本视图提供填充,例如:
android:height="30dp"
android:paddingBottom="10dp"
这应确保显示文本。希望这能有所帮助。我想问题出在您为外部线性布局指定的
android:layout\u height=“45dip”
中。将该行替换为android:layout\u height=“wrap\u content”,我想这将解决您的问题。使用样式:
<style name="CustomTheme" parent="@android:style/Theme.Light">
<item name="android:windowTitleSize">30dp</item>
</style>
30dp
并添加到清单中:
<activity
android:name=".MainActivity"
android:theme="@style/CastomTheme" >
</activity>
其实不然。我已经试过了。当我查看自定义标题栏的图形布局时,它正确地显示了标题栏。但是,当我在emulator上运行应用程序并使用此自定义布局转到“活动”时,textview会被剪切。如果您可以粘贴自定义标题栏的xml,则解决此问题会更容易。确定。我编辑了我的问题正确的答案!如果您想进一步添加自定义背景色/图像,请参见此处:谢谢。拼写android:theme=“@style/CastomTheme”->android:theme=“@style/CustomTheme”