Color of border on ImageView - android

I write an activity for a gallery. I have ImageView elements in GridView and I see a green border on ImageView when I focus on a given element. How can I change this default color of the border? Is it possible? I don't see any method which enables it.
Any advice will be appreciated.

it's android:listSelector="#..." XML attribute in layout

Related

Imageview Background transparent

I set an image view on activity, but how can I remove the white space around the image view while image is .GIF?
' '
you need to have a background to the Button element, you can try and create a selector drawable and set it to the background of the button (assuming you want pres states)
for more, try reading here
Don't use imageview for png image. Use view or linerlayout.

How do I partially gray out an image when pressed?

I have an image that I use as a button. It is an ImageView within a RelativeLayout. The RelativeLayout is the View that receives the touch events. While touched, I want to partially gray out the image as feedback. How do I do this?
The best way I can think of is to place another View with a black background on top of the ImageView and style it normally 100% transparent, but only 50% transparent when touched. Is there a way to style the RelativeLayout or ImageView directly without using an additional View?
Thanks in advance...
One way you could do it would be to add an onclick method for the ImageView and set a tag for it once it's grayed out and a ColorFilter to gray the view. Then you can un-gray it (provided you want the gray out to be toggled) when clicked again. Here's an example:
Add this to the xml:
<ImageView
...
android:onClick="grayOut"/>
Then in the Activity or View class
public void grayOut(View view) {
// if not grayed
if(view.getTag() != "grayed") {
view.setColorFilter(Color.argb(150,200,200,200));
view.setTag("grayed");
} else {
view.setColorFilter(null);
view.setTag("");
}
}
Use a color filter with a transparent grey color on the view when touched and remove it when you want to remove the grey color. It will be imageView.setColorFilter(transparent grey color); When you want to remove it just set the color filter to null.

How to set the opacity of a ListView row in android?

I want to set the opacity of each and every Listview row using android:alpha. I tried doing so but the row doesn't get the transparent background. I have a colorful background of the layout and I want a glass or transparent type of row of the ListView. How can I do it?. I don;t want to use any adapters for this. So please suggest some simple methods.
View backgroundimage = findViewById(R.id.background);
Drawable background = backgroundimage.getBackground();
background.setAlpha(80);
If you are set opacity of listView us below Code
android:background="#80ColorCode"

How to insert an image in the linear layout?

I just wanted to insert an image in linear layout similar to this
Can anyone help me with this???
You are probably looking for ImageButton since your picture shows something similar to that.
Alternatively, take a look at ImageView
set layout's orientation to horizontal, then add 4 images in xml, one after another, add ids like image1, image2 etc, then call them in your onCreate like ImageView image
ImageView image1 = (ImageView) findViewById(R.id.image1)
and so on, then you can either set "src" attribute in yoru xml or say image1.setImageBitmap or any other method available in ImageView class to set the image you want from your res/drawable/
you can use ImageButton in horizontal LinearLayout
make background of the ImageButton #null
then put the margins between them

Android: ListView xml layout not showing background image when scrolled

I have an Activity with a ListView, I set the background image to the view programatically.
When I scroll down my list, the background image turns to white ( because my theme is Theme.Light.NoTitleBar).
How can I make it scroll with the blue background intact?
If the above point works, how can I change the text color of ListView to white instead of black?
Normal ListView
Scrolling ListView
Pressing ListView item
Use the attribute android:cacheColorHint="#000000" in ListView Tag
Regarding make TextView's color black or white, you can refer here to make a custom TextView for your ListView row, The extra work you have to do is just add another attribut inside TextView tag like this
android:textColor="#FFF" //or #FFFFFF for white
add a attribute on the ListView Tag
android:cacheColorHint="#00000000"// setting as a transparent color
This is due because of an optimization. To remove this, just set the cacheColorHint of your listView to transparent, like this: android:cacheColorHint="#00000000"
Full post here: http://android-developers.blogspot.fr/2009/01/why-is-my-list-black-android.html
You can Wrap that ListView inside on LinearLayout having same background and then remove ListView's Background that should work fine. :)
Please check this answer. I have got the same issue and it is fixed by putting view = null in adapter side.

Categories

Resources