How to disable this behaviour on a ListView - android

I'm developing an Android 2.2 application with a ListView.
I want to disable this:
I have a ListView with three list items. When I press over the first list and, without releasing, I move down through second item and third item. Then, when my finger is over the third item I release it. After that I see that all of them has a black background.
How can I disable this effect?
If you need more details, please tell me.

Use this in your ListView element inside your XML file:
android:cacheColorHint="#android:color/transparent"
However, if your app has a background that is a solid color, then set the cacheColorHint to that color, as having it set to transparent can lead to slow scrolling. For example, if I had a green background:
android:cacheColorHint="#0F0"

Use
android:cacheColorHint="#00000000"
as one of the ListView attributes. This will disable the color caching, which will stop doing this black thing.

Related

Easy way to change Firemonkey button pressed color on Android

This might be one of those forehead-slapping questions, but what I want to do, is make my buttons show orange (xFFFCB447) when they are pressed, just like the Android dialogs do. (picklist for example)
There doesn't seem to be a specific "pressed" TRectangle in the Default Style, and my adding different TRectangles (coloured appropriately doesn't seem to do it either), so my only alternative seems to be to use the Bitmap Style designer to Export the style.png; hope I figure out which part of the image is used for the button pressed before tomorrow afternoon, and Update the image again.
Is there not an easier/quicker way to do it?
Option A) Drop a TRectangle on your button. Set it's Align to Contents. Set it's fill color to Orange. Set it's Opacity to 0.50. Set it's HitTest to False. Set it's Visible to False. In the TButton.OnMouseDown set the TRectangle Visible to True. In the TButton.OnMouseUp set the TRectangle Visible to False. You will also need to set the OnMouseMove of the control that TButton is on to set TRectangle Visible to False as well so if you mouse down and then move away it will be hidden as well.
Option B) Drop a TFillRGBEffect on the TButton. Set it to Orange. Do the same as above to enable and disable the effect on mouse down and up. However, be aware that TFillRGBEffect may be slower than the TRectangle way.
Option C) Just use a TRectangle instead of a TButton. Put a TText or TLabel inside it for the text and align to Contents. Change it's Fill color in OnMouseDown and OnMouseUp.

creating an "elevated button" effect in android

I want the button to appear as though it has space in between the bottom of it's face and the canvas. Then, when clicked, it will appear as though there is no space between the button and the canvas. I know I can style the button with xml to give it those 2 looks but I don't know how to do the elevated look.
My question is how would one go about doing this?
Easiest approach to this is creating 2 background images, each fitting the state you want, then you can either set the backgrounds according the button's state, or change the backgrounds by setting an onTouchListener to the button.

Why does my Android Listview turn from transparent to opaque when I click it?

Why does my Android Listview turn from transparent to opaque when I click it and how can I change that ? The Listview has a background and transparent elements and they scroll and work perfectly, except when I click it. When I click it the clicked element turns opaque and the background is no longer visible.
How can I change the behaviour so that the opacity does not change when I click elements ?
Edit: Could the focus highlight be responsible for this ? How can I disable that ?
Edit: Android 2.3.4, Tegra 2 device, Bitmaps created with Config.ARGB_8888 parameter.
It was the focus as I suspected. It killed the transparency because the focus color is not transparent.
I removed that effect with:
android:listSelector="#00000000"
Add android:cacheColorHint="#0000" to the list view in the xml

Android Widgets with Custom backgrounds not getting Focus

I am using a button with my own back ground color in android and that button is not getting focus what is the problem?
Buttons normally will not have focus by touch. Also focus depends on the background.
So, check the background - it needs to be of type drawable with multiple states or you need to make a gradient. Check Standard Android Button with a different color

Button with background, no cursor

I'm trying to customize my buttons in my view a bit and give them my own look. Whenever I set a picture as a background so that the button looks different though, I seem to lose my cursor. I can use my trackball to go through the items still but when I come to one of my custom buttons the cursor does not show. I have the same problem with some TextViews that I made clickable. Any ideas?
(this is a button which i am trying to give a custom look by giving it a background. when i give it a background though, the cursor does not show when it is over it.)
Your background drawable needs to be a state list drawable (or selector) so that you can provide a background image for the focused state. Take a look at the default background drawable used by buttons on Android:
https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/drawable/btn_default.xml

Categories

Resources