我怎样才能在Android中动态地改变按钮样式? [英] How can I change a button style dynamically in Android?

查看:594
本文介绍了我怎样才能在Android中动态地改变按钮样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要动态地更改按钮的样式,即在Java中code,是这样的:

I want to change the style of a button dynamically, i.e. in Java code, something like:

((Button)findViewById(id)).setStyle("@styles/foo")

<resources>
    <style name="foo">
        <item name="android:adjustViewBounds">true</item>
        <item name="android:maxHeight">100px</item>
        <item name="android:maxWidth">200px</item>
    </style>
</resources>

我还没有看到什么样的setStyle,因此:

I have not seen nothing like setStyle, so:

我必须要改变每一个属性或我可以改变整个风格呢?

do I have to change every single property or I can change the whole style?

推荐答案

看看这个问题:<一href="http://stackoverflow.com/questions/2016249/how-to-programmatically-setting-style-attribute-in-a-view">How以编程方式设置样式属性在视图中

这篇关于我怎样才能在Android中动态地改变按钮样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆