如何在TextInputLayout和TextInputEditText中输入文本时取消自动滚动?

huangapple go评论62阅读模式
英文:

How to remove autoscroll, when I typing text in TextInputLayout and TextInputEditText

问题

I tried to remove and request focus when only if I dont typing text - all don't work. How can I fix that?

TextInputLayout and TextInputEditText inserted in recyclerview

英文:

I tried to remove and request focus when only if I dont typing text - all don't work. How can I fix that?

TextInputLayout and TextInputEditText inserted in recyclerview

如何在TextInputLayout和TextInputEditText中输入文本时取消自动滚动?

答案1

得分: 1

以下是已翻译的内容:

我建议,例如这样做:

...
// 在类的顶部
boolean canScrowVertically = true;
...
...
// 初始化 RecyclerView
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
... 
...
// 初始化 LinearLayout,并重写 canScrollVertically 方法
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context) {
    @Override
    public boolean canScrollVertically() {
        return canScrowVertically;
    }
};
...
...
// 设置管理器
recyclerView.setLayoutManager(layoutManager)
...

然后,您可以操作 canScrowVertically 以禁用/启用滚动。

英文:

I would suggest for example to do something like this:

...
// at the top of the class
boolean canScrowVertically = true;
...
...
// init recycler
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
... 
...
// Init linerLayout and override canScrollVertically method
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context) {
    @Override
    public boolean canScrollVertically() {
        return canScrowVertically;
    }
};
...
...
// Set the manager
recyclerView.setLayoutManager(layoutManager)
...

Then you can manipulate canScrowVertically to disable/enable the scrow.

huangapple
  • 本文由 发表于 2023年4月10日 21:23:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75977525.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定