我正在开发一个基础API11的Android应用程序。我想在所有其他组件的滚动视图中添加列表视图,但我知道这是不正确的。所以,当我添加新的单元格时,我使得列表视图像扩展一样是静态的,但是当我添加滚动视图时,列表视图变得可滚动。请在下面找到Android ScrollView列表视图,但禁用滚动
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/parentLayout">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/parentLayout">
<TextView
android:id="@+id/groupNameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Group Name"
android:gravity="center"
android:textSize="30sp"
android:layout_marginTop="10dp"/>
<EditText
android:id="@+id/grpName"
android:layout_below="@id/groupNameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter group name"
android:textAlignment="center"
android:gravity="center"/>
<TextView
android:id="@+id/grpDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Group Description"
android:gravity="center"
android:textSize="30sp"
android:layout_marginTop="14dp"
android:layout_below="@+id/grpName"
android:layout_alignParentLeft="true" />
<EditText
android:id="@+id/grpDescription"
android:layout_below="@id/grpDescriptionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter description"
android:gravity="center"/>
<TextView
android:id="@+id/individualEA"
android:layout_below="@id/grpDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Individual's Email addresses"
android:gravity="center"
android:textSize="30sp"
android:layout_marginTop="10dp"/>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_below="@id/individualEA"-->
<!--android:orientation="horizontal">-->
<ImageButton
android:layout_width="match_parent"
android:id="@+id/addEmailAddressButton"
android:layout_height="40dp"
android:layout_below="@id/individualEA"
android:src="@mipmap/add_button"
android:background="@color/whitecolor" />
<!--</LinearLayout>-->
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/addEmailAddressButton"
android:id="@+id/eaListView" />
<LinearLayout
android:id="@+id/twoButtonsLayout"
android:layout_width="match_parent"
android:layout_below="@id/eaListView"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/updateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/create_account_button_bg"
android:text="Update"
android:layout_below="@id/eaListView"
android:padding="7dp"
android:layout_weight="1"
android:layout_margin="7dp"
android:layout_marginTop="30dp"
android:textColor="@color/whitecolor"
android:textSize="40sp" />
<Button
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/delete_account_button_bg"
android:text="Delete"
android:layout_below="@id/eaListView"
android:layout_margin="7dp"
android:padding="7dp"
android:layout_weight="1"
android:textColor="@color/whitecolor"
android:textSize="40sp" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
的XML下面的截图是我需要,但屏幕不滚动和列表视图静态和扩大。这发生在我评论滚动视图和相对布局时。
为了使其滚动的,我添加滚动视图和相对布局,但滚动视图使得列表视图滚动,并降低等示于下面的屏幕快照列表视图的大小。
在横向模式下,它通过使屏幕可滚动和列表视图为静态的方式工作。
我的问题是如何使屏幕滚动与列表视图静态和扩大像纵向和横向的第一个屏幕截图? P:我想过使用回收器视图和卡片视图,但基础API是旧的,因此我无法继续使用它。
谢谢
为什么你不试试ExpandableHeightListView –
你有没有试过NestedScrollView? https://developer.android.com/reference/android/support/v4/widget/NestedScrollView.html –