【问题标题】:Is there a declarative way to create tabbed layouts on Android?是否有在 Android 上创建选项卡式布局的声明性方式?
【发布时间】:2011-04-18 02:42:09
【问题描述】:

Tab Layout tutorial on the Android Developers site 展示了如何使用大量重复的程序代码将选项卡添加到 TabHost。

是否有在 Android 上创建选项卡式布局的声明方式?类似以下内容?

<?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">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <Tab android:text="Artists"
                 android:icon="@drawable/ic_tab_artists"
                 android:href="artists_frame"/>
            <Tab android:text="Albums"
                 android:icon="@drawable/ic_tab_albums"
                 android:href="albums_frame"/>
            <Tab android:text="Songs"
                 android:icon="@drawable/ic_tab_songs"
                 android:href="songs_frame"/>
        </TabWidget>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp">
            <TextView android:id="artists_frame"
                      android:text="This is the Artists tab."/>
            <TextView android:id="albums_frame"
                      android:text="This is the Albums tab."/>
            <TextView android:id="songs_frame"
                      android:text="This is the Songs tab."/>
        </FrameLayout>
    </LinearLayout>
</TabHost>

(如果存在,FrameLayout 将一次只显示一个子视图。)

【问题讨论】:

    标签: android tabs android-layout tabbed-interface tabbed-view


    【解决方案1】:

    很遗憾,没有。 (我之前遇到过这个错误:body must be at least 30 characters; you enter 18)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多