ListView Scrolling

2019-08-28 02:19发布

I have three items in a ListView. The reason I have chosen the ListView is so I can use a Divider and a List Selector on these items.

However I do not need/want the scrolling aspect of the ListView. Ie. When I select/drag an item from the list, I dont want it to scroll..

Is it possible to disable this somehow? Or will I have to add the items using a LinearLayout and find another way of using a list divider and selector?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-28 02:48

If you dont need to scroll listview, you can add the list item to a linear layout as well you can design it also through xml file. And for put a DIVIDER to it just take a "View" widget. Put it height 1 dip and width fill_parent. You can give color to this view through background color. Try it. i have done it many times.

查看更多
Summer. ? 凉城
3楼-- · 2019-08-28 02:52

I'm not sure how well this will work for you, but you can disable overscroll (available in android-9 and above):

listView.setOverScrollMode(View.OVER_SCROLL_NEVER);

and then also hide the scroll bars:

listView.setVerticalScrollBarEnabled(false);

After this, if your list does not exceed the screen size then it shouldn't be able to scroll.

查看更多
登录 后发表回答