【问题标题】:Layout with ListView and TabHost on Android在 Android 上使用 ListView 和 TabHost 进行布局
【发布时间】:2012-02-26 18:50:23
【问题描述】:

我想做一个这样的布局:

操作栏的东西很好,我让它工作了。但是当我创建ListView 时,带有图像的左侧列表显示在整个显示器上,因此您看不到右侧的TabHost。那么如何在左侧制作ListView,在右侧制作TabHost,使列表占20%,标签占80%?

这样您就可以在列表中选择图像并在选项卡中对其进行处理。它适用于平板电脑,我使用 Honeycomb 3.0 API。 我的布局是这样的:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/id_list_view"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent" />

</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >


<TabHost
    android:id="@+id/tabhost"
    android:layout_width="wrap_content"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/linearLayout3"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </TabWidget>

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </FrameLayout>
    </LinearLayout>
</TabHost>
</LinearLayout>

【问题讨论】:

    标签: android image list tabs tablet


    【解决方案1】:

    我建议您使用Fragments 制作此屏幕,这是实现您想要的最佳和正确的方法

    【讨论】:

      【解决方案2】:

      保持两个垂直线性布局的布局权重属性分别为 0.2 和 0.8,并保持两个垂直线性布局的布局宽度等于 0 像素。

      【讨论】:

        猜你喜欢
        • 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
        相关资源
        最近更新 更多