且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用包含在 ScrollView 中的 ListView 的滚动

更新时间:2022-10-29 22:27:22

将它们添加到 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).