Android选项卡主机布局顶部的文本

Android选项卡主机布局顶部的文本,android,android-layout,android-tabhost,Android,Android Layout,Android Tabhost,我仿效了这个例子,使它起了作用 现在我想表示“欢迎!!!”布局中选项卡上方的文本,如图1所示 这是我当前的布局文件。但它没有显示欢迎信息 <?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="f

我仿效了这个例子,使它起了作用

现在我想表示“欢迎!!!”布局中选项卡上方的文本,如图1所示

这是我当前的布局文件。但它没有显示欢迎信息

<?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:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="top"
            android:layout_gravity="top"
            android:padding="5dp">
            <TextView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/cc_welcome" android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:text="Welcome"
                android:gravity="top" android:padding="50dp" android:textColor="#ffffff"/>
        </LinearLayout>
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="bottom"
        android:layout_gravity="bottom"
        android:paddingTop="50dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_alignParentTop="true"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
        </LinearLayout>

</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">
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <RelativeLayout
            android:id="@+id/welcome"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/cc_welcome" 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:text="Welcome"
                android:layout_centerInParent="true"
                android:textColor="#ffffff"/>
        </RelativeLayout>
        <RelativeLayout
            android:layout_below="@id/welcome"
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_alignParentTop="true"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@android:id/tabs"/>
        </RelativeLayout>
    </RelativeLayout>
</TabHost>

我已经更新了代码。你现在可以试试吗

您将更好地了解线性和相对布局