【问题标题】:Edittext scrolling inside Recyclerview and NestedScrollView android在 Recyclerview 和 NestedScrollView android 中滚动 Edittext
【发布时间】:2018-02-14 07:31:56
【问题描述】:

我在 RecyclerView 中有一个 inputType textMultiLine 的 edittext,它又在 NestedScrollView 中。我有一个功能,我必须在 NestedScrollview 中使用 Recyclerview。 RecyclerView 滚动已被 NestedScrollingEnabled 禁用为 false。在这个 Recyclerview 里面,有一个 itemtype 里面有 edittext。此编辑文本是多行且 100 dp,如果垂直,内容将不适合,内容将被剪切,导致最大高度。那么如何让我的edittext在嵌套滚动视图中滚动

我已使用以下代码启用 Edittext 滚动:

<EditText
        android:id="@+id/etYesDescription"
        style="@style/EditTextStyle"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:inputType="textMultiLine"
        android:imeOptions="actionDone"
        android:overScrollMode="always"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical" />

但它仍然不能滚动,我怎样才能使我的 Edittext 滚动工作?

【问题讨论】:

  • 不准确。添加更多细节。
  • 编辑了问题。请检查
  • 我贴出的答案有look and apply,希望对你有帮助!!

标签: android android-layout android-edittext kotlin android-nestedscrollview


【解决方案1】:

你可以通过这个以编程方式实现看看

 EditText etYesDescription= (EditText) findViewById(R.id.etYesDescription);
 etYesDescription.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (v.getId() == R.id.comment1) {
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    switch (event.getAction() & MotionEvent.ACTION_MASK) {
                    case MotionEvent.ACTION_UP:
                        v.getParent().requestDisallowInterceptTouchEvent(false);
                        break;
                    }
                }
                return false;
            }
        });

希望对你有帮助!!

【讨论】:

  • 非常感谢,您的解决方案对我有帮助。
  • 如何转换成if?
猜你喜欢
  • 1970-01-01
  • 2015-09-11
  • 1970-01-01
  • 2019-10-17
  • 1970-01-01
  • 1970-01-01
  • 2021-04-11
  • 2016-03-19
  • 1970-01-01
相关资源
最近更新 更多