DrawableLeft attribute on spinner on Android? - android

When you have a Button for example, you can use android:drawableLeft to make it an icon at the left of the button:
Now, is there an attribute to use it on spinner? android:drawableLeft is not an attribute in Spinner, so is it possible to have the same result, but in a Spinner?

This is an unsupported attribute for Spinner. You must use a third-party library or make your own XML template for it.

Related

How to set margin for all TextView using styles.xml

I've read from another post that it's possible to set attributes like color to every TextView in an application: Setting global styles for Views in Android. However, I can't set layout_margin nor layout_height and layout_width attribute using that method to any textView, using "android:textviewStyle". On the other hand, if I use the style attribute and reference it to a style with all the attributes above, it works. Is there a way that you can use global styles and still set margin?
Thank you in advance
You can set padding instead of margin and you will have the same result.

Access a value from the current theme in an xml layout

I want a specific TextView to have the same font size as a Button, but they appear to be different. If my Button is not setting a custom textSize, how can I grab this value from the current theme and set it to the textSize of my TextView?
It should be fairly simple with styles. Buttons parent is android.widget.TextView so you could make a style that uses this as parent and overwrite the default textSize. Then let both use this style.

Setting attribute values dynamically

There are always a few attribute values that Android doesn't explicitly define how to change and set dynamically for views. In my case, I'm trying to set the ListView's vertical scroll bar drawable. There's no method in the ListView class that lets you set this. I can only define this in the XML using android:scrollbarThumbVertical="#drawable/new_scroll_bar". Is there ANY workaround that would let me change attributes not otherwise defined dynamically?
It seems impossible, since the document doesn't refer to a corresponding method to set that XML attribute.
In the docs it says it corresponds to the global resource attribute:
android.R.attr.scrollbarThumbHorizontal
You can set this equal to a drawable programatically.
Ref: http://developer.android.com/reference/android/view/View.html#attr_android:scrollbarThumbVertical
Let me know if that is what you were trying to get to.

Android, how to add some right padding to text in a spinner?

I'm developing an Android app (API level 8).
How do I add some right padding to the style of spinners layout?
With the default (Theme.black) style, the right arrow box is placed too close to the end of text in the (closed) spinner.
In your xml, use the android:paddingRight attribute.
In your XML file for the layout, use, for example
android:layout_marginLeft="5dip"

How to set AutoCompleteTextView drop down background to transparent in Android?

As the subject suggests , how to set the transparent background to AutoCompleteTextView dropdown. I can apply any style to the view(TextView) that dropdown box shows but to make the drop down itself transparent I am not able to do !
Any hints or solution ?
Thanks
set android:popupBackground to #0FFF in xml
Thanks , got what I was looking for ,
I can change background image of dropdown using
setDropDownBackgroundResource();
and set semi-transparent png.
You have two options:
XML Attribute:
android:popupBackground
The background to use for the popup window.
May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".
Java Attribute
setDropDownBackgroundResource
Sets the background of the auto-complete drop-down list.

Categories

Resources