Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的TabWidget看起来不像应该的样子?_Android_Tabwidget - Fatal编程技术网

Android 为什么我的TabWidget看起来不像应该的样子?

Android 为什么我的TabWidget看起来不像应该的样子?,android,tabwidget,Android,Tabwidget,我想创建一个简单的TabActivity,并在开发人员站点上按照教程进行操作。实现很好,但是布局让我很困扰。首先,文本是白色的,当背景是白色和灰色时,当背景是灰色时。我认为常规行为会适得其反。但底部的这条白线也丢失了,它应该连接不同的选项卡 <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height

我想创建一个简单的TabActivity,并在开发人员站点上按照教程进行操作。实现很好,但是布局让我很困扰。首先,文本是白色的,当背景是白色和灰色时,当背景是灰色时。我认为常规行为会适得其反。但底部的这条白线也丢失了,它应该连接不同的选项卡

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </TabHost>

    <include layout="@layout/menu_back_only" />

</LinearLayout>
以下是我的布局:

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </TabHost>

    <include layout="@layout/menu_back_only" />

</LinearLayout>
常规选项卡布局

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </TabHost>

    <include layout="@layout/menu_back_only" />

</LinearLayout>

选择操作系统

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </TabHost>

    <include layout="@layout/menu_back_only" />

</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item 
        android:drawable="@drawable/menu_home"
        android:state_selected="true" />

    <item 
        android:drawable="@drawable/menu_logout" />

</selector>

这就是它现在的样子:

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </TabHost>

    <include layout="@layout/menu_back_only" />

</LinearLayout>

好的,似乎是手机(HTC Legend)产生了错误。找到了这个线程:设置目标SDK版本就可以了。笨蛋

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </TabHost>

    <include layout="@layout/menu_back_only" />

</LinearLayout>