Кнопки над Recycler View в Котлине - PullRequest
0 голосов
/ 06 января 2019

В моем проекте у меня есть RecyclerView и я пытаюсь отобразить элементы с помощью RecycleView. Все работает нормально, но кнопка в приведенном ниже коде не показывает первый элемент утилита и скрывает его. Любая помощь приветствуется.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="TestFragment">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/testrv"
        android:layout_width="match_parent"
        android:layout_height="563dp">

    </android.support.v7.widget.RecyclerView>
    <LinearLayout
        android:id="@+id/next_prev_button"
        android:layout_below="@+id/rv_homepost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="50dp"
        android:layout_weight="1"
        android:gravity="center_vertical">

        <Button
            android:id="@+id/prev_button"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="4dp"
            android:layout_weight="1"
            android:enabled="true"
            android:text="Previous" />

        <View
            android:layout_width="1dp"
            android:layout_height="match_parent" />

        <Button
            android:id="@+id/next_button"
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="4dp"
            android:layout_weight="1"
            android:enabled="true"
            android:text="Next" />
    </LinearLayout>

</FrameLayout>

1 Ответ

0 голосов
/ 06 января 2019

Во-первых, совет - это не очень хороший подход для определения конкретного размера для вида переработчика - это зависит от разрешения / размеров устройства и может работать не на всех. Обычно я должен переставить его между видами компоновки, чтобы он поместился между доступным пространством.

Я не уверен, правильно ли я понял проблему - но, увидев результат вашего кода в Android Studio, я считаю, что это кнопки, которые перекрываются с представлением рециркулятора, верно?

Предложение:

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

<LinearLayout
    android:id="@+id/next_prev_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical">

    <Button
        android:id="@+id/prev_button"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="4dp"
        android:layout_weight="1"
        android:enabled="true"
        android:text="Previous" />

    <View
        android:layout_width="1dp"
        android:layout_height="match_parent" />

    <Button
        android:id="@+id/next_button"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="4dp"
        android:layout_weight="1"
        android:enabled="true"
        android:text="Next" />
</LinearLayout>

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

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