невозможно прокрутить содержимое в относительном или линейном формате - PullRequest
0 голосов
/ 24 апреля 2018

У меня есть три линейных макета в верхнем относительном макете

  • во первых у него есть просмотр списка
  • во втором у него есть другой линейный макет
  • вв-третьих, у него есть сетка

    вариант 1: когда просмотр списка загружает контент с сервера, он занимает полный экран, поэтому я не вижу его ниже линейного макета

    вариант 2: когда я применяю скролл всамый верхний вид, внутренний просмотр списка не прокручивается правильно.Вложенное представление прокрутки не работает.

    Еще одна идея, которую я хочу попробовать: я хочу показать все содержимое списка, чтобы не было необходимости прокручивать содержимое списка (прокрутка верхнего реального макета может показать содержимоеlisview) .. но не знаю, как добиться этого макета и будет ли это работать или нет. Как просмотреть содержимое всех трех линейных макетов на одном экране?Пожалуйста, помогите вам будет оценено.

вот макет

<RelativeLayout 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/container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context="TeamDetails">
    <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:layout_margin="2dp"
            android:background="@drawable/cardview_shadow"
            android:elevation="2dp"
            android:orientation="vertical"
            android:visibility="visible">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="5dp"
                android:text="Squad"
                android:textColor="@color/primaryDarkColor"
                android:textStyle="bold" />
            <GridView
                android:id="@+id/players_list_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:columnWidth="120dp"
                android:gravity="center"
                android:horizontalSpacing="5dp"
                android:numColumns="auto_fit"
                android:padding="10dp"
                android:stretchMode="columnWidth"
                android:verticalSpacing="5dp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="2dp"
            android:background="@drawable/cardview_shadow"
            android:elevation="2dp"
            android:orientation="vertical"
            android:visibility="visible">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:gravity="center"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:layout_marginLeft="5dp"
                    android:layout_marginRight="10dp"
                    android:layout_weight="1"
                    android:text="Fixtures"
                    android:textColor="@color/primaryDarkColor"
                    android:textStyle="bold" />

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="3dp"
                    android:layout_weight=".28"
                    android:background="@drawable/menu_bg"
                    android:elevation="1dp"
                    android:gravity="right|end"
                    android:orientation="horizontal"
                    android:visibility="visible">

                    <Spinner
                        android:id="@+id/spinner"
                        android:layout_width="243dp"
                        android:layout_height="11dp"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center"
                        android:layout_marginLeft="5dp"
                        android:background="@android:color/transparent"
                        android:gravity="center"
                        android:spinnerMode="dialog" />

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_centerVertical="true"
                        android:layout_gravity="center"
                        android:src="@drawable/drop"
                        android:visibility="visible" />

                </RelativeLayout>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/squad_containerr"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <ListView
                    android:id="@+id/list_view"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:elevation="2dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="2dp"
            android:background="@drawable/cardview_shadow"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="5dp"
                android:text="Detail"
                android:textColor="@color/primaryDarkColor"
                android:textStyle="bold" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

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

                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

Ответы [ 3 ]

0 голосов
/ 24 апреля 2018

ScrollView может содержать не более одного ChildView. Замените ваш верхний RelativeLayout на ScrollView и добавьте другие макеты ниже ScrollView. Добавьте LinearLayout ниже ScrollView и вставьте в него ListView.

0 голосов
/ 24 апреля 2018

Используйте свойство веса следующим образом: (Измените значение веса в соответствии с желаемым коэффициентом разделения пользовательского интерфейса)

<LinearLayout
    android:weightSum="3"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

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

    </LinearLayout>

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

    </LinearLayout>

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

    </LinearLayout>

</LinearLayout>
0 голосов
/ 24 апреля 2018

Пожалуйста, инициализируйте высоту макетов равной 0 и присвойте свойство веса, чтобы они могли разделить весь экран для всех макетов.

Пример: если вы инициализируете вес двух макетов равным 1, а последний - двумя. Весь экран будет разделен на 4 части, и часть будет назначена каждому виду в соответствии с нумерацией веса, но последний макет примет 2 части, так как вес 2.

...