Listview hide scrollbar when not scrolling - android

As the title says I want to hide a listview's scrollbar when the listview isn't scrolling and show it when scrolling. I know this can be done very easy by setting "android:fadeScrollbars" as an application style if the API is 5 or newer. But I want the feature to be available on all android devices. So I've implemented the "setOnScrollListener" method, and switched the scrollbar visibility using the setVerticalScrollBarEnabled method. This works great on G2. The problem is that on Motorola Milestone the SCROLL_STATE_IDLE event isn't received when the scrolling stops, and so the scrollbar remains visible.
Thank you for reading!

Instead of using setOnScrollListener, I've used setOnTouchListener and switched the scrollbar's visibility at the MotionEvent.ACTION_DOWN and MotionEvent.ACTION_UP events.

Whatever I could have said as a solution has already been done by you.
Sorry!
but thanks a lot for posting that this particular Moto has this issue.

Related

WebView in ListView drawn twice (Why and how to solve?)

I am using a ListView with a WebView every 30 items for special HTML ads (animated) which are provided from a WebServer. This normally works okay. But sometimes it seems to draw the content of the WebView twice as seen in the screenshot below. The WebView continues animating but the misplaced (left bottom) drawing stays the same. When one interacts with the screen (scrolls) the wrongly drawn space disappears.
Now my questions are:
Why is this happening?
How can I prevent this from happening?
My current guess for Nr. 1 is: Somehow the WebView gets positioned in the left bottom just for a quick time where it as well draws. Then it gets positioned correctly but the ListView does not redraw that area because it thinks all is still at the same position.
Thanks to anyone who can help.
UPDATE:
I used the same WebView with the animation centered in a RelativeLayout. The same problem occurred there. So the problem is not in the ListView.
WebViews don't go well with ListViews, you may have to do a lot of hacks, including handling touch events, etc.
If you list doesn't display an 'infinite' list of items, or at least the list is never too big, you can maybe give a try on this custom listview from this other post: https://stackoverflow.com/a/21878703/684582
it was designed to support a ListView inside a ScrollView, but it might just help you on your problem without much redesign. I hope it helps! Good luck!
I found the problem in the WebView coming from the advertiser. The problem seems to be setting the LayerType to HARDWARE. That caused the Problem. Setting the the LayerType to NONE or SOFTWARE the problem went away. Now I just wonder WHY that caused the problem.
A normal WebView uses LAYER_TYPE_NONE by default.
Solution in short:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

Android WebView jumping to the bottom

I have a ScrollView with 20 WebViews inside (yes, I know it's heavy but right now it's the best solution I've found). The WebViews are used to display forum posts.
I'm getting a very weird behavior on my Nexus 4 (it doesn't happen on some other devices I've tested) which is driving me crazy.
I have the first post visible and just a little bit of the second one visible. Now I want to scroll and instead of starting scrolling by putting the finger in the first post I put the finger on the portion of the second post that is visible. The WebView of that second post immediately jumps to the bottom which is a very annoying behavior while scrolling.
If you feel appropriate I can record a video of this behavior and upload to YouTube or you can search for AndroidPIT in the Play Store and check the behavior yourself in the Forum section. I won't post the link to the Play Store to avoid being called a spammer.
Thanks in advance.
From comment: "Have you tried setting your webview to non focusable and non clickable as it appears as it's trying to display the entire content of the item you are pressing on as you scroll"
Apparently View#setFocusable (view.setFocusable(false)) worked.
Make sure that the scrolling is handled by the scrollview in stead of the webview. I believe setting the Webview.canscrollvertically to false might fix the problem, let me know if it helped.

PreferenceActivity background in ics is gone during scroll

i'm using PreferenceActivity in my app for settings and when tried to set a background and it looks fine untill the user scroll. during the scroll there is background only below the text (see links to images below)
after the scroll it goes back to how it was before (the way it should look)
the problem happens only on ics (on nexus one it works fine)
did anyone saw that problem before and know how to fix it?
thanks.
thats how it looks before scrolling
http://i.stack.imgur.com/4aPKX.png
and thats how it looks during scrolling
http://i.stack.imgur.com/zDbgU.png
you have to set the cache color hint to 0
java: getListView().setCacheColorHint(0)
or xml: android:cacheColorHint="#00000000"
http://developer.android.com/resources/articles/listview-backgrounds.html

Android: ScrollBar bug in 2.2 for ListView

The problem appears in Android 2.2. It seems cool because it can auto-hide.But I don't like it quite much because the bar is an indicator for "Whether there is more content not present on the widget". Hiding it maybe neat, but may get the users wrong sometimes. In ListView, I find it a fatal bug at all. When there is more content to show, no scrollbar present, AND when wipe the screen down-wards, no scroolbar appears. Only when use the traceball or Dpad to move focus, there appears the scrollbar. BUT THERE IS WORSE: when you wipe down-wards to move the scrollbar down, nothing happens! The touch feature is almost disabled here.
Can anyone help me here? Thanks!
Maybe answers there will help you
Android ListView that does not scroll?
I had a listview inside of a scrollview. After I'd commented scrollview it was possible to use listview's scrolling.
The weird thing is, that this problem occurs only on Android 2.2.
I am using a listView in android 2.2 and it works just fine . The vertical scrolling happens implicitly without the inclusion of a scroll view . Hope your ListView id is #android:id/list.
And a small correction , to move down the list , you need to wipe the screen UPWARDS not DOWNWARDS ....

android listview scroll past top

Does anyone know how to achieve the "scroll past top" functionality that you see in some apps (like the HTC Sense email app for example) where when you scroll up to the top of the list and try to scroll up past that, it appears to pull down, and when you release it springs back up?
Take a look at this library: https://github.com/johannilsson/android-pulltorefresh. I think it implements the behavior you are looking for.
As far as I know, there is no built-in way to achieve this look with the default ListViews. Everyone who has done this implemented their own custom ListView widget that supports this functionality.

Categories

Resources