半屏TabHost

时间:2015-02-09 13:25:21

标签: android android-tabhost viewflipper

如何在屏幕的下半部分显示一个Tabhost,显示静态图片(每次刷卡时都不能重新加载/重新显示)。

+--------------------------+---+---+
| =                        | * | ? |   < Action Bar with Help, Settings and 
+--------------------------+---+---+     a sliding drawer from the left
|                                  |     should be present.
|                                  |
|                                  |
|              static              |   < This should, regardless of the tab 
|           picture/map            |   < selected, be the same.
|                                  |
|                                  |
|                                  |
+----------------------------------+
| TAB1 | TAB2 | TAB3 | TAB4 | TAB5 |   < There will be about 20 Tabs, if
+----------------------------------+     that is of any relevance
|                                  |
|     TEXTTEXTTEXTTEXTTEXTTEXT     |   < Only the Text should, depending on 
|     TEXTTEXTTEXTTEXTTEXTTEXT     |   < the selected Tab, be switched
|     TEXTTEXTTEXTTEXTTEXTTEXT     |   < accordingly.
|     TEXTTEXTTEXTTEXTTEXTTEXT     |
|                                  |
+----------------------------------+

如果无法做到这一点,我可以使用什么?我是TextSwitcher的负责人,但这并没有像tabHost那样持续不断的滑动动画。

非常感谢。

1 个答案:

答案 0 :(得分:0)

执行此操作的一种方法是在Fragment中有两个垂直定位的Activity,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<fragment android:name="com.whatever.ImageFragment"
          android:id="@+id/image_fragment"
          android:layout_weight="1"
          android:layout_height="0dp"
          android:layout_width="match_parent" />

<fragment android:name="com.whatever.TabHostFragment"
          android:id="@+id/tabhost_fragment"
          android:layout_weight="2"
          android:layout_height="0dp"
          android:layout_width="match_parent" />

</LinearLayout>

顶部Fragment将包含MapViewImageView,而底部片段将包含FragmentTabHost,文本为Fragment。请注意,在这种情况下,FragmentTabHost将被强制使用getChildFragmentManager()方法获取文本Fragment