Recyclerview移至屏幕,可见性移出屏幕

时间:2019-07-31 06:12:30

标签: android android-recyclerview

当我在回收站视图"visibility = VISIBLE"中设置可见的东西时,如果它接近底部或顶部,则它会显示在屏幕外,我想知道是否有任何方法可以使recyclerview在{ {1}}被调用。

我遇到的另一个问题是向那些要求moveTo跳转到回收者视图中的目标项目的人移动到VISIBLE <<。

我很难使它看起来不错并跳到正确的位置,我认为带有"(ctx as MainActivity).moveTo(id.toInt() + 7)"的工具栏可能会弄乱它。

我尝试在移动对象上添加数字,并设法使键盘在打开时向上移动,以专注于编辑文本,但无法解决其他问题。

工具栏

"app:layout_scrollFlags="scroll|enterAlways""

最重要的是,我第一次尝试使用moveto时会遇到一些空错误,因此我设置了if来避免它,并使用+7来确保它失败了,不知道这是否是最好的方法。

<com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:layout_weight="1"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            app:title="Gerenciador de Prioridades"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways">
        </androidx.appcompat.widget.Toolbar>

    </com.google.android.material.appbar.AppBarLayout>

我非常感谢您可以提供的任何帮助或建议。

编辑: enter image description here

当该项目太靠近底部且可见性消失时,当我单击该项目以获取可见性= VISIBLE时,它将消失在屏幕外,因此我想知道是否有使其向上滚动或将其保留在滚动视图中的方法,但是对用户可见。

1 个答案:

答案 0 :(得分:1)

使用include将您放置在应用程序栏布局中

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:layout_weight="1"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        app:title="Gerenciador de Prioridades"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_scrollFlags="scroll|enterAlways">
    </androidx.appcompat.widget.Toolbar>

<include layout="@layout/content_main" />

</com.google.android.material.appbar.AppBarLayout>

然后将您的视图添加到内容主布局中,这应该可以解决问题