禁用包含在 ScrollView 中的 ListView 的滚动 [英] Disable scrolling of a ListView contained within a ScrollView

查看:39
本文介绍了禁用包含在 ScrollView 中的 ListView 的滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的用户显示个人资料屏幕.

它必须具有三个视图(2 个 Buttons 和一个 ImageView)和一个 ListView 以显示该用户制作的内容.>

但是,我不希望 ListView 滚动.相反,我希望它根据需要尽可能大,并将我的所有视图放在 ScrollView 中,因此前三个视图与 ListView 一起滚动.这当然不能按预期工作.

我所有的三个项目都在一个 LinearLayout 内.我想将它们作为 ListView 中的第一项,但这导致它们可以被选为第一项,并且不得不进行一些不必要的编码.

有没有一种简单的方法可以做到这一点,还是我必须坚持将布局设为 ListView 中的第一项?

解决方案

将它们添加到 ListView 作为第一个 Item 似乎是一个不错的解决方案.

要使视图无法选择,只需获取视图和 .setClickable(false).

I want to show a Profile screen for my users.

It must have three views (2 Buttons and a ImageView) and a ListView to show the content made by that user.

However, I don't want the ListView to scroll. Instead, I want it to be as big as needed, and to put all my views inside a ScrollView, so the three first views scroll out with the ListView. This, of course, does not work as intended.

All my three items are inside a LinearLayout. I thought of making them the first item in the ListView, but this leads to them being selectable as the first item, and having to do some unneeded coding.

Is there a way to do this the easy way or will I have to stick with making the Layout the first item in my ListView?

解决方案

Adding them to the ListView as first Item seems like a pretty good solution.

To make the View unselectable just get the view and .setClickable(false).

这篇关于禁用包含在 ScrollView 中的 ListView 的滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆