NestedScrollView не показывает все содержимое - PullRequest
0 голосов
/ 02 февраля 2019

Я пытаюсь использовать ScrollView для моей mainActivity .Внутри ScrollView используется горизонтальная LinearLayout .Содержимое LinearLayout превышает размер экрана.Я ожидал, что смогу прокрутить их внутри ScrollView, однако, ScrollView показывает только несколько пикселей ниже последнего вида, который просеивается на экран.Мне нужно, чтобы он показывал и прокручивал все содержимое.

<ScrollView 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:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:fillViewport="true"
android:isScrollContainer="false"
tools:context="Activities.MainActivity">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:weightSum="12">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/relativeLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="3"
        android:background="@color/website_top_color">

        <Spinner
            android:id="@+id/countriesSpinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="20dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Spinner
            android:id="@+id/currencySpinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="4dp"
            app:layout_constraintStart_toEndOf="@+id/countriesSpinner"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="4dp"
            android:drawablePadding="5dp"
            android:drawableStart="@drawable/ic_package"
            android:text="Premium Packages"
            android:textColor="@android:color/white"
            app:layout_constraintStart_toEndOf="@+id/currencySpinner"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/mainActivityLogin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="16dp"
            android:layout_marginTop="4dp"
            android:text="Login"
            android:textColor="@android:color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/view"
            app:layout_constraintTop_toBottomOf="@+id/textView" />

        <View
            android:id="@+id/view"
            android:layout_width="1.5dp"
            android:layout_height="0dp"
            android:layout_marginEnd="16dp"
            android:layout_marginTop="4dp"
            android:background="@android:color/white"
            app:layout_constraintBottom_toBottomOf="@+id/mainActivityRegistration"
            app:layout_constraintEnd_toStartOf="@+id/mainActivityRegistration"
            app:layout_constraintTop_toTopOf="@+id/mainActivityLogin"
            app:layout_constraintVertical_bias="1.0">

        </View>

        <TextView
            android:id="@+id/mainActivityRegistration"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:layout_marginEnd="16dp"
            android:layout_marginTop="4dp"
            android:text="Register"
            android:textColor="@android:color/white"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView" />
    </android.support.constraint.ConstraintLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="50dp"
        android:layout_marginTop="10dp"
        android:src="@mipmap/logo" />

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="25dp"
        android:layout_weight="3"
        android:background="@android:color/darker_gray"
        app:cardBackgroundColor="@android:color/darker_gray"
        app:cardCornerRadius="5dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="2.5dp"
            android:background="@android:color/white">

            <android.support.v7.widget.SearchView
                android:id="@+id/mainActivitySearch"
                android:layout_width="match_parent"
                android:layout_height="match_parent"></android.support.v7.widget.SearchView>
        </RelativeLayout>
    </android.support.v7.widget.CardView>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginEnd="100dp"
        android:layout_marginLeft="100dp"
        android:layout_marginRight="100dp"
        android:layout_marginStart="100dp"
        android:layout_marginTop="20dp"
        android:layout_weight="3"
        android:background="@android:color/darker_gray"
        android:orientation="horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="1dp"
            android:background="@android:color/white"
            android:weightSum="6">

            <RelativeLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2.98">

                <TextView
                    android:id="@+id/exchange"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:drawableStart="@drawable/ic_exchange"
                    android:text="( 0 )"
                    android:textColor="@color/website_top_color"
                    android:textSize="20sp" />
            </RelativeLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="@android:color/darker_gray" />

            <RelativeLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="2">

                <ImageView
                    android:id="@+id/shopping_cart"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:src="@drawable/ic_shopping_cart" />
            </RelativeLayout>

            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="@android:color/darker_gray" />

            <RelativeLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1">

                <ImageView
                    android:id="@+id/drawer"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:src="@drawable/ic_list" />
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="LATEST FEATURED PRODUCTS"
        android:textColor="@android:color/black"
        android:textSize="24sp" />
    <android.support.v4.view.ViewPager
        android:id="@+id/banner"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="25dp"
        android:layout_weight="12" />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="BUNDLED PRODUCTS"
        android:textColor="@android:color/black"
        android:textSize="24sp" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="CLASSIFIED"
        android:textColor="@android:color/black"
        android:textSize="24sp" />

    <android.support.v7.widget.RecyclerView
        android:id="@+id/gridLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="9" />

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="27">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@mipmap/parralax_vendor"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="OUR VENDOR"
                android:textColor="@android:color/black"
                android:textSize="24sp" />

            <android.support.v4.view.ViewPager
                android:id="@+id/vendor"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>

Выше мой xml.

1 Ответ

0 голосов
/ 13 февраля 2019

Я решил эту проблему.Я обнаружил, что после удаления всех weightSum s и layout_weight s мой ScrollView работал отлично.

...