Icon and Background color together - android

I need to add both background and an icon and I ought to use background property for both in xml. I cannot set both at the same time so how can I handle this?

You can use the XML for setting the background, and the property "drawableRight" or "drawableLeft" to set the Icon this is the way I do it.

Related

android programatically set Theme to edittext and add drawable background to button

I want to programmatically create theme and set it to my Edittext. (I need to set colorControlNormal and colorControlActivated properties). So I guess I need somehow create theme in my code, give those 2 properties to it and than apply it to my Edittext.
Also I need to programatically give button the drawable background. But I need programmatically set color to this drawable stroke.
How can I achieve this in code?

How to set progressBar color in android?

So far I am just seeing an option to set background. I want to set the filled portion to one color and the unfilled portion to another color.
I think you could achieve this, setting background of progressBar to color of unfilled portion and setting progressTint to filled portion color.

Android UI Button Alpha Property

If I change the Alpha setting on a Button widget to make it translucent, then add a background image to the Button, will the image also be translucent?
Yes. Changing the background property will override any of the styling you have applied to the button and use only that. So if you use a Material-style button that has custom colors, then apply a background property, the "button" will disappear and be only a perfect rectangle of whatever color (including alpha) that you set, with text/drawables on top.

Android floating action button with custom background

Is it possible to set a custom background to a floating action button? For example, I'd like the fab to have background color with a gradient, and the "plus" icon on top of that. I've only seen simple background color so far. I'd like to keep using the design support library from Google.
You set background color to Floating Action Button through this property:
android:backgroundTint= "#color/colorPrimary"
and this does not accept #drawable. Which means you can not apply any drawable so my answer is NO, you cannot apply gradient to fab.
According to Google Buttons: Floating Action Button documentation, Google suggests to avoid such designs.:
Have a custom xml for the background and have a drawable for the src. With this you might be able to solve your problem. Hope this helps.

how can I customize and change the background color of spinner in android?

I want to change the background color of spinner and customize spinner. When I used this code in xml android:background="#000000" the color changed but the arrow on the spinner disappears. How can I cuztomize spinner and change the background color without disappearing the arrow?
The arrow is black (or close to it) by default, so it won't show up on a black background. You can change the arrow with the android:dropDownSelector attribute in your XML.
The "background" attribute on a spinner refers to a drawable which contains the background color and the arrow. By specifying a color for the background, there is no longer any arrow. To fix this you need to provide a new 9 patch drawable with the arrow in it.

Categories

Resources