Disable list skipping on Samsung Galaxy Tab 2.3.3 android

I need to completely disable overcroll in my lists so that I can implement my own super scroll functions.

It seems simple enough to look at the main listview classes by simply setting the overscroll mode to OVERSCROLL_NEVER. This is a great job on my Samsung Galaxy s2. But does not work. For Galaxy Tab 2.3.3.

Has anyone had a lot of experience with Samsung ListView settings that can help me?

+6
source share
3 answers

You must set the list height for the fix value. If your content is dynamic, there is a good function for measuring the actual list after the adapter reboots:

  public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); listView.requestLayout(); } 

you must call this static method with your list as a parameter after configuring your adapter. Now you can add scrollview (inside - your list and other views). I would say that this behavior in 2.3.3 used to be a small mistake ... there is no easy way to include a list in the scroll, except as I described. For this reason, they introduced OVERSCROLL_NEVER :)

Code from DougW!

+2
source

This worked for me on a Samsung Galaxy Tab (with Android 2.2):

 try { // list you want to disable overscroll // replace 'R.id.services' with your list id ListView listView = ((ListView)findViewById(R.id.services)); // find the method Method setEnableExcessScroll = listView.getClass().getMethod("setEnableExcessScroll", Boolean.TYPE); // call the method with parameter set to false setEnableExcessScroll.invoke(listView, Boolean.valueOf(false)); } catch (SecurityException e) {} catch (NoSuchMethodException e) {} catch (IllegalArgumentException e) {} catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} 
+3
source

Not my solution, but works for me :)

https://gist.github.com/DHuckaby/3919939

+1
source

Source: https://habr.com/ru/post/913234/


All Articles