开发者

Android Tabs in XML

开发者 https://www.devze.com 2023-02-18 01:12 出处:网络
My question is simple.Is it possible to create tabs entirely in xml?My app has only one a开发者_StackOverflow社区ctivity.I want to have 2 tabs that show the same data but in slightly different layouts

My question is simple. Is it possible to create tabs entirely in xml? My app has only one a开发者_StackOverflow社区ctivity. I want to have 2 tabs that show the same data but in slightly different layouts. It seems like it should be but I cannot find anything on it.

TIA,

Mark


You can do something like this. Your layout for each tab would go inside a tabwidget. This will have it's limitations that you would easily get around if you employ a simple TabHost

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

    <!-- Tabs at bottom of screen -->
    <TabWidget
    android:background="@drawable/textview_top"
    android:layout_weight="12"
    android:id="@android:id/tabs"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    />
   </TabHost>
0

精彩评论

暂无评论...
验证码 换一张
取 消