Макет выхода из экрана - PullRequest
0 голосов
/ 02 ноября 2019

У меня есть 2 вида: SearchView и SwipeRefreshLayout, которые находятся внутри ConstraintLayout.

rendered layout

Я установилмежду ними корректные ограничения, но при рендеринге это показывает, что SwipeRefreshLayout выходит из экрана, и при запуске приложения я не вижу последние элементы, так как они «вне экрана».

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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/questionsLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    tools:context=".fragments.QuestionsFragment">

    <SearchView
        android:id="@+id/search"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipeContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/search">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/items_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical">

        </androidx.recyclerview.widget.RecyclerView>

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginBottom="64dp"
        android:clickable="true"
        android:elevation="4dp"
        android:focusable="true"
        android:src="@drawable/ic_keyboard_arrow_up_black_24dp"
        app:fabSize="mini"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Подскажите, пожалуйста, что я здесь не так делаю?

Заранее благодарю за помощь!

1 Ответ

1 голос
/ 07 ноября 2019

Попробуйте это решение:

Макет

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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/questionsLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white">

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/adView"
        android:fillViewport="true"
        android:scrollbars="none">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/dim_3"
            android:layout_marginRight="@dimen/dim_3"
            android:orientation="vertical">

            <SearchView
                android:id="@+id/search"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                app:layout_constraintTop_toTopOf="parent" />

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipeContainer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toBottomOf="@id/search">

                <android.support.v7.widget.RecyclerView
                    android:id="@+id/items_list"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scrollbars="vertical">

                </android.support.v7.widget.RecyclerView>

            </android.support.v4.widget.SwipeRefreshLayout>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="6dp"
        android:layout_marginBottom="64dp"
        android:clickable="true"
        android:elevation="4dp"
        android:focusable="true"
        app:fabSize="mini"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:srcCompat="@drawable/ic_ads" />
</android.support.constraint.ConstraintLayout>
...