[英]Recyclerview move to and visibility going off-screen
當我在回收器視圖中將可見性設置為"visibility = VISIBLE"
時,如果它接近底部或頂部,則屏幕外顯示,我想知道在調用VISIBLE
時是否有任何方法可以使recyclerview
焦點。
我"(ctx as MainActivity).moveTo(id.toInt() + 7)"
另一個問題是移動到"(ctx as MainActivity).moveTo(id.toInt() + 7)"
<<對於那些要求moveTo跳轉到回收者視圖中的目標項目的人。
我很難使它看起來不錯並跳到正確的位置,我認為帶有"app:layout_scrollFlags="scroll|enterAlways""
的工具欄可能會使其混亂。
我嘗試將數字添加到移動對象上,並設法使鍵盤在打開時向上移動,以專注於編輯文本,但無法解決其他問題。
工具列
<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>
最重要的是,我第一次嘗試使用moveto時會遇到一些空錯誤,因此我設置了if來避免它,並使用+7來確保它失敗了,不知道這是否是最好的方法。
if (id != 1.toLong()) {
(ctx as MainActivity).moveTo(id.toInt() + 7)
}
我非常感謝您可以提供的任何幫助或建議。
當此項目離底部太近且可見性消失時,當我單擊該按鈕以獲取可見性= VISIBLE時,它將消失在屏幕外,因此我想知道是否有使其向上滾動或將其保留在滾動視圖中但對於用戶。
使用包含將您放置在應用程序欄布局中
<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>
然后將視圖添加到內容主布局中,這應該可以解決問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.