在代码中修改TextView的DrawableRight图片
来源:互联网 发布:b2b商城app源码 编辑:程序博客网 时间:2024/05/17 22:45
TextView的xml
- <TextView
- android:id="@+id/textciew1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="#000"
- android:drawableRight="@drawable/button_nav_down"
- android:gravity="center_vertical"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
- android:text="展开"
- android:textColor="#fff"
- />
setCompoundDrawables(Drawable left,Drawable top,Drawable right,Drawable bottom)
Drawable可以通过 Drawable nav_up=getResources().getDrawable(R.drawable.button_nav_up);得到但是API提示,setCompoundDrawables() 调用的时候,Drawable对象必须调用setBounds(int left, int top, int right, int bottom)方法,于是我们加一行代码就可以了
- nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
代码合在一起是这样的:
- Drawable nav_up=getResources().getDrawable(R.drawable.button_nav_up);
- nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
- textview1.setCompoundDrawables(null, null, nav_up, null);
0 0
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 在代码中修改TextView的DrawableRight图片
- 代码中修改TextView的DrawableRight图片
- 在代码中设置Textview的drawableRight
- TextView的DrawableRight图片
- 如何在代码中动态为TextView/Button设置drawableRight
- 在代码中修改TextView的Drawable图片
- 关于在代码中设置TextView的drawableright drawleft 等的属性问题总结
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 安卓在代码中设置TextView的drawableLeft、drawableRight、drawableTop、drawableBottom
- 博客转移到github上了,csdn的博客就关了。
- 成功解决未能为 Visual Studio 创建 Application Data 文件夹
- Android 编程下 Touch 事件的分发和消费机制
- Git基础学习记录(一)
- Excel函数
- 在代码中修改TextView的DrawableRight图片
- 监督学习,非监督学习与半监督学习
- iOS国际化时遇到的异常:read failed: the data couldn't be read because it isn't in the correct format
- BZOJ 3747: [POI2015]Kinoman
- 编写PHP扩展
- IOS IAP APP内支付 Java服务端代码
- 数据结构之字符串ADT
- 支付宝即时到账接口PC和wap移动端的区别
- Java多线程之synchronized和volatile