繁体   English   中英

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

[英]tab widget text below the tab

我是新来的android并用两个tabwidget创建了tabhost,一切顺利,现在我还显示了两个tab。两个不同的活动。但是问题是我为两个不同的tab指定的文本在下面,而运行应用程序。下面我将屏幕截图用于理解

屏幕截图: 在此处输入图片说明

文本标记为红色,因此有任何方法可以使文本与中心对齐。 另外,我还针对用户点击的不同状态使用了可绘制图像。 谢谢你的帮助。

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>

该部分是另一个布局,它具有两个按钮,所有这些都同步,并且我将其包含在此布局中

尽管

android:textAlignment="center"

你应该使用

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

在tab_host元素内

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM