我正在開發一個基礎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 –