Background size getting changed - android

I'm changing Background color of a button programmatically as below
Button button =(Button)findViewById(R.id.one);
button.setBackgroundColor(0xFFFF0000);
But after this the size of button getting increased.. Im using relative layout in UI.

Default button background drawable has some kind of margins. These margins are just transparent pixels on the sides of the image. When you set background color for a button these margins disappear because the whole rectangle of the button is filled with the color.

Related

Background color is applied in the whole line

I want the background color (blue) to be applied only where I have letters. Check the image below
Click here to see the example
Not aligned to the right example
Set layout width to wrap content
set TextView width as wrap content, then color will be only in text area

I want to make a layout like this below in the image given:The blue color trapezium at the bottom of the screen

I want to make a layout like this below in the image given. The blue color trapezium at the bottom of the screen

How to make opacity of view with transparent, infliction, subtraction

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)...

Draw compound drawable outside EditText background

I'm trying to create an EditText with custom background, and a compound drawable to the left, but outside the background (currently it's appearing overlapped to the background); something like this.-
Is this possible?
If your background is the white box - then no, it's not possible to draw outside of the TextView's bounds.
Although you can use a compound background, set the orange colour with the white box inside of it as your TextView's background, then you'll be able to set the mailbox as the left drawable of your TextView.

Layout background with corners and child layout drawable

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.

Categories

Resources