如何设置属性“android:drawableTop"运行时的按钮 [英] How to set property "android:drawableTop" of a button at runtime

查看:19
本文介绍了如何设置属性“android:drawableTop"运行时的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时设置按钮的android:drawableTop"属性

How to set property "android:drawableTop" of a button at runtime

推荐答案

使用

button.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);

将 Drawables(如果有)设置为出现在文本的左侧、上方、右侧和下方.如果您不想在那里使用 Drawable,请使用 0.可绘制对象的边界将设置为其内在边界.

Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.

如果你使用

button.setCompoundDrawables(left, top, right, bottom);

将 Drawables(如果有)设置为出现在文本的左侧、上方、右侧和下方.如果您不想在那里使用 Drawable,请使用 null.Drawables 必须已经有 setBounds(Rect) 叫.

Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had setBounds(Rect) called.

这篇关于如何设置属性“android:drawableTop"运行时的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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