繁体   English   中英

如何使用长项目实现列表视图?

[英]How can I implement a list view with long items?

我实现了一个ExpandableListView 但是它的Items很长而且没有出现在屏幕上!

我使用HorizantalScrollView来解决这个问题。 但它用(header with)调整到最小。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<HorizontalScrollView
    android:id="@+id/horizontalScrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <ExpandableListView
            android:id="@+id/lstUploadList"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </ExpandableListView>
    </LinearLayout>
</HorizontalScrollView>

我怎样才能解决这个问题 ?

您不需要水平滚动视图,因为您需要设置 layout_height="wrap_content" 。

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

            <ExpandableListView
                android:id="@+id/lstUploadList"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >
            </ExpandableListView>
        </LinearLayout>

或者,如果您想水平滚动布局,则必须将水平布局的宽度设置为 wrap_content

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<HorizontalScrollView
    android:id="@+id/horizontalScrollView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ExpandableListView
            android:id="@+id/lstUploadList"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </ExpandableListView>
    </LinearLayout>
</HorizontalScrollView>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM