1

我是 android 新手,已经用两个 tabwidget 创建了 tabhost,一切正常,现在我也用两个选项卡显示两个不同的活动。但问题是我为两个不同的选项卡指定的文本在下面,而运行应用程序。下面我放截图以供理解

截屏: 在此处输入图像描述

文本被标记为红色,所以有什么方法可以将该文本与中心对齐。我还使用可绘制图像来处理不同的用户点击状态。谢谢你的帮助。

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>

该部分是另一种布局,它有两个按钮同步所有和我在这个布局中包含的主页

4

1 回答 1

0

尽管

android:textAlignment="center"

你应该使用

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

tab_host 元素内部

于 2013-02-23T12:40:37.410 回答