[英]Listview not scrolling
我有一个可扩展卡的列表视图。 每张卡有2个框架视图,一个用于非展开视图,一个用于展开视图。 在展开的视图中,我还有另一个列表视图-不会滚动。 谁能告诉我为什么? 这是一些代码:
第一个列表视图:
<LinearLayout
android:background="@null"
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/groups_listview"
android:layout_width="match_parent"
android:divider="@null"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
第二个列表视图(扩展的卡片内容):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
xmlns:fontawesometext="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_expandablelistitem_card_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/corners_white_transparent"
android:orientation="vertical" >
<ListView
android:id="@+id/friendsInGroupListview"
android:layout_width="match_parent"
android:layout_height="200dp"
android:divider="@null" >
</ListView>
</LinearLayout>
扩充卡:
<?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"
android:descendantFocusability="blocksDescendants"
android:padding="16dp" >
<FrameLayout
android:id="@+id/activity_expandablelistitem_card_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</FrameLayout>
<FrameLayout
android:id="@+id/activity_expandablelistitem_card_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp" >
</FrameLayout>
</LinearLayout>
我从来没有使用wrap_content
在layout_height
也不layout_width
,它会导致性能问题,因为你可以阅读这里 。 设置静态宽度/高度也不是一个好主意,因为它可能导致多个设备的布局问题。
话虽如此,我总是这样定义ListView
:
<ListView
android:id="@+id/who_list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="vertical">
</ListView>
在LinearLayout
中仅使用此视图设置您的layout_weight
,您可以确保ListView
具有良好的布局渲染,并在需要时启用滚动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.