【问题标题】:RecyclerView scroll moves unexpectedlyRecyclerView 滚动意外移动
【发布时间】:2017-06-10 01:31:42
【问题描述】:

我有一个垂直的 RecyclerView,其中每个单元格都有一个水平的 RecyclerView。水平 RecyclerView 中的每个单元格都有一个 EditText。当 EditText 在单击事件中获得焦点时,滚动将移动到最后一个单元格。

有没有人有过这种经历并且知道解决这个问题的方法?

编辑文本:

<EditText
    android:id="@+id/item_grade_et_quantidade"
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:inputType="number"
    android:imeOptions="actionDone"
    android:selectAllOnFocus="true"
    android:text="0"/>

水平 RecyclerView XML:

<android.support.v7.widget.RecyclerView
     android:id="@+id/rv_list_produto_childs"
     android:scrollbars="horizontal"
     android:layout_width="match_parent"
     android:fadeScrollbars="false"
     android:layout_height="185dp" />

水平 RecyclerView Java:

rvProdutoChilds.setHasFixedSize(true);
LinearLayoutManager mLinearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
rvProdutoChilds.setLayoutManager(mLinearLayoutManager);

问题示例:

【问题讨论】:

  • 添加更多水平单元格并测试它是否真的滚动到最后 - 或者只是滚动到编辑文本的最左侧位置
  • @twl 我用更多单元格进行了测试。卷轴移动到最后。
  • my problem一样,你找到解决办法了吗?

标签: java android xml android-recyclerview


【解决方案1】:

如果垂直回收器视图的每个单元格中的努力文本数量是固定的,您应该尝试使用水平滚动视图而不是水平回收器视图。

【讨论】:

  • 我使用 RecyclerView 是因为我需要它的性能。
【解决方案2】:

尝试将属性 android:focusableInTouchMode="false" 放在 EditText 父布局中。

【讨论】:

  • 我试过这个,但它不能作为解决方案。
猜你喜欢
  • 1970-01-01
  • 2015-02-27
  • 1970-01-01
  • 1970-01-01
  • 2020-07-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-05
相关资源
最近更新 更多