【安卓】在java代码中设置drawableLeft时如何给定合适尺寸?
2014-07-07 17:54
267 查看
textView.setCompoundDrawables(drawable, null, null, null);时看不到图片,是因为需要手动给定drawable对应的尺寸,即用drawable.setBounds。
如果该drawable为图片,可直接drawable.setBounds(0,0,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());。
即直接给定图片自身尺寸,此时效果和在xml中给定一样。
如果该drawable为图片,可直接drawable.setBounds(0,0,drawable.getIntrinsicWidth(),drawable.getIntrinsicHeight());。
即直接给定图片自身尺寸,此时效果和在xml中给定一样。
相关文章推荐
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom显示和隐藏
- Android 如何在Java代码中手动设置控件的marginleft
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 在java代码中设置TextView中DrawableLeft的方法
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- Android在代码中设置控件的drawableLeft/Right/Top/Bottom
- 在android的java代码中对控件的"layout_marginLeft"进行设置
- android 通过代码设置drawableLeft
- 如何解决java.library.path属性在代码中设置不生效问题
- Java 编程下 Eclipse 如何设置单行代码显示的最大宽度
- 【原创】如何在Android中为TextView动态设置drawableLeft等
- 4、android xml中drawableTop(drawableBoottom、drawableLeft、drawableRight)在java代码中的动态配置
- 使用代码为textview设置drawableLeft
- Android如何在java代码中设置margin