开发者

How to applicate android styles without change .java?

My question is simple, I want to improve an android application using styles, so without change the *.java file…what I mean is use always “android.R.layout“ in the .java, but be allowed to change the appearance of spinner (and its options), the color of a textview, the background…etc

I’ve researched that defining styles.xml like this:

<resources>

    <style name="GreenHeader" >
        <item name="android:textColor">#04B40开发者_如何转开发4</item>
        <item name="android:typeface">normal</item>
        <item name="android:textSize">30pt</item>
        <item name="android:gravity">center</item>
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
    </style>

    <style name="RedHeader" parent="@style/GreenHeader" > 
        <item name="android:textColor">#FF0000</item>
    </style>
</resources>

and calling

:android:theme="@style/RedHeader" 

in the manifest.xml, when you use (for example) in the layout:

<Spinner
style= "@style/RedHeader"

something change…but it doesn’t works well, I don’t know what more I need, maybe some other xml file called themes…but I don’t know, I’ve found hours and hours without result I need help to improve it, please!! Could anyone help me???


Sorry you can not change styles programatically in android, but you can change a view or widget background programatically if it is enough for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜