我如何使整个显示滚动 [英] how do I make my whole display to be scrollable

查看:56
本文介绍了我如何使整个显示滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的餐厅制作一个应用程序,当用户进入餐厅页面时,他或她将能够看到所有可选项目,如下图所示:

在这里您可以看到我突出显示了一部分,而该部分是Expandable listView.事实是,当我滚动可扩展列表时,我希望整个页面都向上滚动,而不仅是整个方向的可扩展列表都可以滚动.

这是我的XML代码:

 < LinearLayout xmlns:android =" http://schemas.android.com/apk/res/android"xmlns:app =" http://schemas.android.com/apk/res-autoxmlns:tools ="http://schemas.android.com/tools"android:layout_width =" match_parent"android:layout_height =" match_parent"android:fitsSystemWindows =" true"android:orientation ="vertical"工具:context =.UI_Activity.RestaurantDetail"< LinearLayoutandroid:layout_width =" match_parent"android:layout_height =" match_parent"android:orientation =" vertical">< LinearLayoutandroid:layout_width =" match_parent"android:layout_height =" wrap_content"android:orientation =水平">< ImageButtonandroid: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"/>< TextViewandroid: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>< LinearLayoutandroid:layout_width =" wrap_content"android:layout_height =" wrap_content"android:orientation =" vertical">< androidx.cardview.widget.CardViewandroid: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"< ImageViewandroid:id =" @ + id/RestaurantImage"android:layout_width =" match_parent"android:layout_height =" match_parent"android:scaleType =" centerCrop"/></androidx.cardview.widget.CardView>< TextViewandroid:id =" @ + id/RestaurantNameandroid:layout_width =" match_parent"android:layout_height =" wrap_content"android:gravity ="center"android:padding ="5dp"android:text =" RestaurantName"android:textSize ="20sp";android:textStyle =" bold"/>< TextViewandroid:id ="@@ id/RestaurantTheme"android:layout_width =" match_parent"android:layout_height =" wrap_content"android:gravity ="center"android:padding ="5dp"android:text ="这家商店是基于真实事物android:textSize =" 15sp"android:textStyle ="斜体"/>< RelativeLayoutandroid:layout_width =" match_parent"android:layout_height =" wrap_content"android:layout_marginTop =" 5dp"android:orientation =水平">< TextViewandroid:layout_width =" wrap_content"android:layout_height =" wrap_content"android:padding ="8dp"android:layout_marginStart =" 5dp"android:text ="要约"android:textSize =" 15sp"android:textStyle =" bold"/>< TextViewandroid: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 ="没有报价%"android:textColor ="#9BA176"android:textSize =" 15sp"android:textStyle =" bold"/></RelativeLayout>< TextViewandroid:layout_width =" match_parent"android:layout_height =" wrap_content"android:text ="菜单项"android:gravity ="center"android:textSize =" 18sp"android:padding ="5dp"/></LinearLayout>< ExpandableListViewandroid:id =" @ + id/RestaurantItemList"android:layout_width =" match_parent"android:layout_height =" match_parent"android:footerDividersEnabled ="false";android:headerDividersEnabled ="false";android:smoothScrollbar =" false"/></LinearLayout> 

任何人都可以告诉我要进行哪些更改或布局,或者在现有代码中必须进行任何更新吗?

我想要的是,当我滚动可扩展列表视图时,我希望整个显示都随它一起滚动.

先谢谢您

解决方案

我能够通过为ExpandableListView创建自定义类来解决此问题.在进行了一些更改之后,终于可以实现我一直在寻找的结果,谢谢.

您可以参考以下链接:此处

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

解决方案

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

这篇关于我如何使整个显示滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆