我的问题很简单。是否可以完全在 xml 中创建选项卡?我的应用只有一项 Activity 。我想要 2 个选项卡显示相同的数据,但布局略有不同。看起来应该是,但我在上面找不到任何东西。
TIA,
标记
最佳答案
你可以这样做。每个选项卡的布局都将放在一个选项卡小部件中。如果您使用简单的 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>
关于XML 中的 Android 选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5362589/