开发者

Styles and themes in Android

I'm trying to learn something about styles and themes for And开发者_运维知识库roid. I've found that, if I add the android:theme attribute in the manifest for Application or Activity, style is applied to the entire app/activity. I think it would be useful to be able to define a style that is applied for example only to buttons. Do you know if there is a way to apply a certain style only for a certain kind on Views, as in CSS?


Here's a general example:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="CustomButton" parent="@android:style/Widget.Button">
        <item name="android:textColor">#FF0000</item>
    </style>
    <style name="CustomTheme" parent="android:Theme">
        <item name="android:buttonStyle>@style/CustomButton</item>
    </style>
</resources>


It's easy to do, just read the official reference:

http://developer.android.com/guide/topics/ui/themes.html

EDIT

Obviously you'll need to specify the style you create on each button/view you want it to be applied (like in css, for the class attribute)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜