Bitmap colors change while scrolling - android

I have a ListView that has a subtle gradient bitmap in the background of each item. I noticed that when I scroll the list, the background gradient becomes banded and changes color. The gradient is a dark gray and when it scrolls is becomes subtly green and banded. It basically looks like the quality of the images greatly decreases as it scrolls.
Most of the time, as soon as it finishes scrolling, it returns to the normal quality. Sometimes it actually stays poor quality even after scrolling stops. On a Nexus One it almost always stays low quality after scrolling.
Is there a way to avoid this?
Note: This is not the common ListView background problem discussed here: http://developer.android.com/resources/articles/listview-backgrounds.html
Here is an enlarged screen cap to show the difference. On the left side is the background normally. On the right half you can see what it looks like when it scrolls.

You need to add android:cacheColorHint="#0000" to your ListView in xml.

Related

Gradient background scaled after resizing ViewGroup

In my app, I have ConstraitLayout with a gradient background. In a runtime, this ConstraitLayout can be resized. The problem I faced is that gradient drawable "isn't scaled". I will show an image to explain it better:
In the green circles, You can see that the color before and after resizing at the and of ConstraitLayout is different. Is this possible to force an app to set a gradient in the full range of colors?
The only way I have found to do it is to set ConstraitLayout background every time its changes. I think it is not the best way to do it, especially in my case when ConstraitLayout size was changing in on onTouch event, so my App has to change it so many times. But I didn't see any problems while using this solution.

White background when rotating a webview

I am trying to "play" with a webView. I slide it and rotate it, and it works fine. The problem is that when I rotate it, I get a ugly white rectangle in the background emcompassing the webview. I tried to change the background color but it's still there, and it's still very white and ugly.
Any idea how I can make it go away?
I guess it's the background color of the window. You can change it in your theme file
Extremly strange. While playing around, I tried to modify the alpha value of the webview. Turns out it make the white background disappear! When setting any value other than 1 with the setAlpha method, the white immediatly goes away.
Another thing appear thought : I have a TextEdit just above the webview in my layout, with a black blackground. When I rotate the webview, part of it's corner go over the TextEdit, and this part (on th TextEdit) become white...
I corrected this with invalidate(), but this is really strange.
I suspect both occurrences are bugs.

Reduce the contrast and brightness of a background layer

I have a menu screen, with an animated background layer. This background is calculated runtime, hence it is not a simple sequence of images, and it uses graphic elements that are used inside the application itself.
As soon as these graphics elements are studied to be very colourful and visible, the background animation sometimes makes the menu that is on the foreground a little confused.
So, I have to reduce the contrast of the background animation.
What is the best practice to reduce the background contrast/brightness without changing the graphic elements? (or maybe blur the background layer)
And more, would it be possible to reduce the contrast/brightness ONLY on a portion of the screen, the one below and around the menu buttons, and leave the rest of the screen as it is?
Thank you very much.
You can make the menu layer larger (think of it as a "padding" around the menu itself); if that "padding" is dark (black or close to it, depends on the effect you want to achieve, maybe even 50% gray if you only want to reduce contrast) then you can set its alpha value to something that achieves your effect of "dimming" the background. Or let the "padding" have an alpha gradient so the darkening fades out/the background fades in.

background image transparency taking snapshot of layout android

I am having a View and i have placed a background image.Taking the snapshot works fine in this case.
But i setAlpha to make background image semi transparent then snapshot becomes blackish in color depending on how much I am making it Transparent.
How to programmatically take a screenshot in Android?
having seen this link but doesn't help much with this case.
Any help?
if you put an alpha color the screen shot will get a non-color (black) mix on it, always.
If you want a screen shot, and keep your alpha, you'll probably have to remove the alpha, wait it to render on the screen, get the screen shot, and then change it back to alpha.
I know cause I've used this before in an application.

Fading at the bottom of a scrollable list on Android?

I have a long ListView with a white background (android:background="#android:color/white") and transparent cache color (android:cacheColorHint="#00000000"). Two questions:
I am testing on a variety of devices. On older ones, the fade works fine. But on the newer ones, I am not seeing any fade at all, just a sharp cutoff. Why might that be and how do I fix it?
A lot of the times the elements in my list line up so that there is
just enough whitespace at the bottom, that the fade doesn't reach
the text and is not visible. Is there a way to make the fade cover
more of the list?
Found my own answers:
android:requiresFadingEdge="vertical"
android:fadingEdgeLength="48dp"
EDIT: changing to dp instead of sp

Categories

Resources