How to make background opacity of the View (for ex. EditField )with transparent, infliction, subtraction "Screen" like it is in Photoshop?
I know if I set background to "#android:color/transparent" for EditField then white background will be visible, but not main backgrounf of the layout
I need to implement this one:
You can't do it simply.. not by any code.. the only way to do that is to get a drawable .png image(you need photoshop to create it) that has this shape(semi tranaparent on the frame ans fully transparent inthe center with rounded corners).. make it with small width .. and use 9patch tool for stretching (so you can get flexible width)...
Related
I would like to change (map) white color to blue color. How can I do this on ImageView in Android? I tried setColorFilter by PorterDuff / LightingColorFilter / ColorMatrixColorFilter but I can't figure out how to set it up. There is a transparent background around the image.
Try to use Background Tint color function in xml or java code.
or
I would suggest another way. Take on frame layout and place view and then image view.
white portion in image should be transparent use PNG image.
and you can give color to base view color which ever you want.
I need to create an imageview with background drawable like a frame but not getting the required design.
I'm getting these images
But the required designs are
In your layout, set the background to the required colour.
android:background="#FFF9C4"
Then add the ImageView inside the layout and add padding on Left, Right, Top and Bottom of size as per requirement.
You can explore shape too, using shape you can control the corners as well.
I got a picture that I want to use.
I set it as following:
ImageView menu = new ImageView(this);
menu.setLayoutParams(new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT));
menu.setImageResource(R.drawable.menu);
They annoying thing is that I get white pixels on the sides of it cause I want to keep the aspect of the pic.
I can stretch the image by using menu.setScaleType(ScaleType.FIT_XY); but that will make the person on it look really fat. The picture is dark and the pixels are white so they do show quite well. :/
Is there I way I can first apply black color and then the image above that color?
To set a background color to any view on android you can use android:background attribute in layout xml or by calling setBackgroundColor(int id) in java code.
But if you really want just to set the image in bounds you can give a try to android:scaletype="centerCrop"
Using set BackgroundColor will also remove any padding, borders and what not attached to the object.
If that is the result you want, that is a reasonable approach.
If blasting the objects current style will cause problems, I would look to use CSS to set the background color and change the css styles through code if things are happening after page load.
Consider using a border around the image that is colored the way you want to hide what is underneath?
Is it possible in Android to programmatically draw a line using a path, such that the middle section is a solid color but both ends fade from that color to transparent? The path will be a series of calculated coordinates.
Yes, use a generic View widget with a drawable that contains a gradient as its background.
Make sure it extends to match_parent in the direction you want it to cut your layout and it's 1px tall or wide in the other dimension.
The gradient should be a simple linear gradient transparent to solid to transparent.
Here is a very nice tutorial.
Update:
The above link is dead, try this one instead.
Anyone got a clue how to handle following issue:
I have a Layout with background drawable like grey border, then I add padding of the border width to `Layout.
Child Layout has background drawable representing a selector, when pressed its darker gray (see image) and when not pressed its little bit lighter.
How to get rid of that sharp edge in the picture, I can't add margin to child Layout, because the pressed state must fill totally the child Layout.
It seems that the only solution here is to add the margin and suck it, or adjust the background drawables to have rounded corners as well.