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.
Related
how make some thing like this , Image View surround with Text
i mean , image appear inside Text
You can try TextViewOverflowing
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.
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
I wanna make a Gallery, with a picture in the background and a textfield with invisible background... So I can see the text and the Image behind.
I already made the Gallery but i cant figure out how to put text in the foreground.
You create a custom adapter to use for your gallery view, see Hello Gallery tutorial
In the method getView() you have two different ways to achieve the same result:
A. Make an ImageView and a TextView and set the image and text:
ImageView iv = new ImageView(context); //and so on, remember to set the LayoutParams etc to fit your design.
Make a RelativeLayout and add the ImageView and TextView to it
Return the RelativeLayout.
B. Declare a layout in xml, with a RelativeLayout containing a TextView and an ImageView
In getView, inflate this layout, and using
inflatedLayout.findViewById(R.id.myTextView); //and so on
set the text and image and return the layout.
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