Заставить реселлервью заполнить всю страницу - PullRequest
0 голосов
/ 14 октября 2019

У меня есть страница с пользовательским видом переработчика. Я хочу, чтобы элементы, которые я добавляю в программу просмотра, появлялись в списке. Приложение работало нормально, пока я не обновил свою библиотеку AppCompact. Но, по сути, я привязал свой FAB к макету Координатора, но я получил исключение IllegalStateException, и для его решения мне пришлось привязать его к одному из дочерних элементов макета Координатора. Я выбрал обзор переработчика. Но проблема сейчас в том, что представление переработчика не заполняет всю страницу. Он показывает только один элемент (я могу прокручивать их), но они занимают место только один - как просмотр по одному за раз. Как сделать так, чтобы макет работал так же, как и до обновления?

Это мой xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    android:layout_height="match_parent">

    <!--<include layout="@layout/base_toolbar"/>-->
    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/myCoordinatorLayout"
        android:layout_width="match_parent"
        android:gravity="center"
        android:layout_height="match_parent"
        >

        <LinearLayout
            android:id="@+id/reminderEmptyView"
            android:orientation="vertical"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:src="@drawable/empty_view_bg"
                android:layout_width="100dp"
                android:layout_height="100dp"/>

            <TextView
                android:text="Nothing added yet"
                android:textColor="@color/secondary_text"
                android:textSize="16sp"
                android:paddingTop="4dp"
                android:paddingBottom="8dp"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>


        <!--<include layout="@layout/base_toolbar"/>-->


        <!--</android.support.design.widget.AppBarLayout>-->


        <apps.todo.Utility.RecyclerViewEmptySupport
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:id="@+id/toDoRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>


        <android.support.design.widget.FloatingActionBut

Ответы [ 2 ]

0 голосов
/ 14 октября 2019

Попробуй так:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <RelativeLayout
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:id="@+id/reminderEmptyView"
            android:orientation="vertical"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:src="@drawable/empty_view_bg"
                android:layout_width="100dp"
                android:layout_height="100dp"/>

            <TextView
                android:text="Nothing added yet"
                android:textColor="@color/secondary_text"
                android:textSize="16sp"
                android:paddingTop="4dp"
                android:paddingBottom="8dp"
                android:gravity="center"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </LinearLayout>

        <apps.rtkay.pookiev2.todo.Utility.RecyclerViewEmptySupport
            android:id="@+id/toDoRecyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </RelativeLayout>

    <android.support.design.widget.FloatingActionButton
        android:src="@drawable/ic_add_white_24dp"
        android:id="@+id/addToDoItemFAB"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin" />

</android.support.design.widget.CoordinatorLayout>
0 голосов
/ 14 октября 2019

Возможно, вам не нужен этот родительский LinearLayout. Просто скопируйте

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

Это в ваш CoordinatorLayout.

Затем удалите gravity из вашей схемы координат и измените вашу FloatingActionButton на:

<android.support.design.widget.FloatingActionButton
   android:src="@drawable/ic_add_white_24dp"
   android:id="@+id/addToDoItemFAB"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_margin="16dp"
   android:layout_gravity="bottom|end"/>

Это исправит соединениемежду вашим RecyclerView и FAB.

Этот пост в блоге также может вам помочь: https://android.jlelse.eu/coordinatorlayout-basic-8040c74cf426

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...