【发布时间】:2020-08-27 12:35:12
【问题描述】:
我正在为我的餐厅制作一个应用程序,当用户进入餐厅页面时,他或她将能够看到所有可选择的项目,如下图:
在这里你可以看到我已经高亮了一部分,那部分是 Expandable listView。问题是,当我滚动可扩展列表时,我希望整个页面向上滚动,而不仅仅是可扩展列表,当我向任一方向滚动时,整个页面都是滚动的。
这是我的 XML 代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".UI_Activity.RestaurantDetail">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/RestaurantBackKey"
android:layout_marginTop="10dp"
android:layout_width="40dp"
android:layout_marginStart="6dp"
android:layout_height="30dp"
android:gravity="center"
android:background="?attr/selectableItemBackground"
app:srcCompat="@drawable/ic_back_key"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginEnd="52dp"
android:layout_marginTop="5dp"
android:text="@string/app_name"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginStart="8dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="13dp">
<ImageView
android:id="@+id/RestaurantImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</androidx.cardview.widget.CardView>
<TextView
android:id="@+id/RestaurantName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text="RestaurantName"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/RestaurantTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp"
android:text=" This shop is based on the real thing"
android:textSize="15sp"
android:textStyle="italic" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_marginStart="5dp"
android:text="Offers"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/OfferAvailability"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:clickable="true"
android:focusable="true"
android:padding="8dp"
android:text="No Offers %"
android:textColor="#9BA176"
android:textSize="15sp"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Menu Item"
android:gravity="center"
android:textSize="18sp"
android:padding="5dp"/>
</LinearLayout>
<ExpandableListView
android:id="@+id/RestaurantItemList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:smoothScrollbar="false" />
</LinearLayout>
谁能告诉我要进行哪些更改或哪种布局,或者我必须对现有代码进行哪些更新?
我想要的是,当我滚动可扩展列表视图时,我希望整个显示随之滚动。
提前谢谢你
【问题讨论】:
标签: android scrollview expandablelistview android-nestedscrollview