问题
I am making an App for my restaurant, there when the user enters the restaurant page, he or she will be able to see all the selectable Item here is the image below:
Here you can see that I have highlighted a portion and that portion is Expandable listView. The thing is that when I scroll the expandable list VIew I want the whole page to scroll up not just the Expandable List the whole page to be a scroll when I scroll in either direction.
here is my XML code:
<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>
Can anyone tell me what changes to be made or which layout or is there any update That I have to do in my existing code?
What I want is that when I scroll the expandable list View I want the whole display to get scroll along with it.
Thank you in Advance
回答1:
I was able to solve it by making a custom class for ExpandableListView. Where I have made some changes and finally I was able to achieve the result I was looking for either way thank you.
you can refer to this link: here
回答2:
You should probably wrap the entire layout in a NestedScrollView
.
回答3:
Put the whole layout inside a ScrollView
, that will make everything scrollable.
来源:https://stackoverflow.com/questions/63616137/how-do-i-make-my-whole-display-to-be-scrollable