选项卡下方的选项卡小部件文本

时间:2013-02-23 12:13:06

标签: android

我是Android的新手,并且已经创建了tabhost与两个tabwidget一切正常,现在我显示两个不同的活动与两个选项卡也。但问题是我为两个不同的选项卡指定的文本是在运行应用程序时来到下面。我正在为了解理解屏幕截图

截图: enter image description here

文本标记为红色,因此有任何方法可以将该文本与中心对齐。 还有一件事我还使用drawable图像用于不同的用户点击状态。 谢谢你的帮助。

tabhost的xml文件

<?xml version="1.0" encoding="utf-8"?>
<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"
    >

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
        <include layout="@layout/top_portion_layout"/>

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textAlignment="center"
           >
        </TabWidget>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="#808080">
            </FrameLayout>

    </LinearLayout>
</TabHost>

该部分是另一种布局,它具有两个按钮同步全部和家庭 我在这个布局中包括

1 个答案:

答案 0 :(得分:0)

尽管

android:textAlignment="center"

你应该使用

android:gravity="center"
android:layout_gravity="center_vertical"

在tab_host元素