gpt4 book ai didi

android - 如何使我的整个显示可滚动

转载 作者:行者123 更新时间:2023-12-04 08:59:48 27 4
gpt4 key购买 nike

我正在为我的餐厅制作一个应用程序,当用户进入餐厅页面时,他或她将能够看到这里的所有可选项目,如下图:
enter image description here
在这里您可以看到我突出显示了一部分,该部分是可扩展的 listView。问题是,当我滚动可扩展 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>

谁能告诉我要进行哪些更改或哪种布局,或者我必须在现有代码中进行哪些更新?
我想要的是,当我滚动可扩展 ListView 时,我希望整个显示也随之滚动。
先感谢您

最佳答案

我能够通过为 ExpandableListView 创建一个自定义类来解决它。在那里我做了一些改变,最后我能够实现我正在寻找的结果,谢谢。
你可以引用这个链接:here

关于android - 如何使我的整个显示可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63616137/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com