【发布时间】:2011-11-19 15:45:48
【问题描述】:
我有一个基本问题。在许多 tabhost 示例中,我们可以找到带有图像和文本的选项卡。
在我的情况下,我只想显示一个文本,但问题是我的文本水平居中而不是垂直居中(文本位于标签的底部)。
我在框架布局中尝试了:android:layout_gravity="center",但它不起作用。
请问你有什么想法吗?
我的 xml。
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
</FrameLayout>
</LinearLayout>
</TabHost>
已解决:感谢以下教程,我自定义了标签:http://joshclemm.com/blog/?p=136
谢谢
【问题讨论】:
-
很久以前有人问过同样的问题。请阅读本期enter link description here
-
是的,我看到了这篇文章,但我仍然有这个问题。 :(
-
最好使用自定义选项卡,因为默认选项卡具有图标和文本的大小。
-
谢谢。你说得对。由于以下教程,我自定义了我的标签:joshclemm.com/blog/?p=136
标签: android center android-tabhost vertical-alignment