如何在Android中为TextView动态设置drawableLeft等
来源:互联网 发布:手机版淘宝客服在哪里 编辑:程序博客网 时间:2024/05/21 14:59
两种方式:
方式1:手动设置固有边界
1 Drawable drawable = getResources().getDrawable(resId);2 //注意查看方法TextView.setCompoundDrawables(Drawable, Drawable, Drawable, Drawable)3 //的注释,要求设置的drawable必须已经通过Drawable.setBounds方法设置过边界参数4 //所以,此种方式下该行必不可少5 drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());6 setCompoundDrawables(drawable, null, null, null);
方式2:自动设置固有边界
1 setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);2 //setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(resId), null, null, null);
0 0
- 如何在Android中为TextView动态设置drawableLeft等
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- Android动态布局,并动态为TextView控件设置drawableLeft、drawableRight等属性添加图标
- Android 动态设置TextView的drawableLeft等属性
- 动态使用代码为Textview设置drawableLeft
- Android 动态设置TextView drawableLeft的方式
- 动态设置TextView的android:drawableLeft属性
- Android 使用代码为textview设置drawableLeft
- Android使用代码为textview设置drawableLeft
- TextView中设置DrawableLeft
- Android TextView 代码中设置DrawableLeft 图片
- Android TextView 代码中设置 drawableLeft
- Android在代码中设置控件的drawableLeft等
- 动态为TextView控件设置drawableLeft图标,并设置间距
- 如何在代码中动态为TextView/Button设置drawableRight
- Android TextView drawableLeft 在代码中实现
- Android TextView drawableLeft 在代码中实现
- 关于在TextView中设置DrawableLeft,DrawableRight等不显示的问题
- 用JNI实现java调用C
- 使用Unity的50个建议
- jQuery.form.js插件回调函数失效的解决办法
- Zend Studio技巧大全:[1]Zend Studio快捷键
- 数据流程图与程序/系统结构图等的解释与说明
- 如何在Android中为TextView动态设置drawableLeft等
- openfire-Spark二次开发——修改设置窗口
- VirtualBox官网下载及安装教程
- Mysql 存储过程查询结果赋值到变量的方法
- 自定义onTouchEvent之ACTION_MOVE不响应
- 程序日志--ios“页面控制”程序
- servlet 处理过程
- 二叉查找树 BST
- 数据库