Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.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布局问题_Android_Performance_Android Layout - Fatal编程技术网

巨大的android布局问题

巨大的android布局问题,android,performance,android-layout,Android,Performance,Android Layout,我刚开始使用Android,我正在做一个简单的应用程序,我希望它看起来像这样: ------------------------------------------- | | | | | T A B | T A B | T A B | | SELECTED | | | |---------------------------

我刚开始使用Android,我正在做一个简单的应用程序,我希望它看起来像这样:

-------------------------------------------
|             |             |             |   
|   T  A  B   |   T  A  B   |   T  A  B   |
|  SELECTED   |             |             |   
|-----------------------------------------|
|                                         |
| VIEW FLIP CONTENT                       |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
-------------------------------------------
<?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"
        android:padding="5dp">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" />
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />    
    </LinearLayout>
</TabHost>
也就是说,我有一些选项卡,每个选项卡都有一个视图翻转组件。这使他们能够拥有内部“选项卡”。问题是,使用此配置,我必须在单个活动上运行所有内容!此外,我的布局越来越大(见附图)。我怎样才能解决这个烂摊子?是否将每个选项卡作为单个活动运行


可以将所有选项卡放在不同的活动中。为父活动创建简单布局,如下所示:

-------------------------------------------
|             |             |             |   
|   T  A  B   |   T  A  B   |   T  A  B   |
|  SELECTED   |             |             |   
|-----------------------------------------|
|                                         |
| VIEW FLIP CONTENT                       |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
-------------------------------------------
<?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"
        android:padding="5dp">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" />
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />    
    </LinearLayout>
</TabHost>
就是这样,现在您有了一个包含两个选项卡的tabhost,要添加更多选项卡,只需继续添加更多tabhost即可。当然,您需要更改每个选项卡的文本,并填写您自己的活动,而不是“YourFirstActivity”和“YourSecondActivity”


有关教程,请查看此处:

可以将所有选项卡放在不同的活动中。为父活动创建简单布局,如下所示:

-------------------------------------------
|             |             |             |   
|   T  A  B   |   T  A  B   |   T  A  B   |
|  SELECTED   |             |             |   
|-----------------------------------------|
|                                         |
| VIEW FLIP CONTENT                       |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
-------------------------------------------
<?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"
        android:padding="5dp">
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1" />
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />    
    </LinearLayout>
</TabHost>
就是这样,现在您有了一个包含两个选项卡的tabhost,要添加更多选项卡,只需继续添加更多tabhost即可。当然,您需要更改每个选项卡的文本,并填写您自己的活动,而不是“YourFirstActivity”和“YourSecondActivity”

有关教程,请查看以下内容: