简体   繁体   中英

tab widget text below the tab

i am new to android and had create the tabhost with two tabwidget all thing goes ok and fine and now i am displaying two different activity with two tab also.but the question is the text which i am specifying for two different tab is coming below while running the app.Below i am putting the screenshot for understanding

Screenshot: 在此处输入图片说明

the text are mark as red so is there any way to align that text to the center. one more thing im also using the drawable image for different state of user click. thanks for any help.

the xml file for the tabhost

<?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>

the portion is another layout which having two button sync all and home which i am including in this layout

inspite of

android:textAlignment="center"

you should use

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

inside tab_host element

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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