在代码中修改TextView的DrawableRight图片
来源:互联网 发布:2017优化设计英语答案 编辑:程序博客网 时间:2024/04/30 20:55
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
- Android系统启动过程
- web前端开发你应该知道的好消息
- Android Ormlite的综合查询
- Spring IoC的理解----找女朋友的方法
- 跟siki老师学C#第二天
- 在代码中修改TextView的DrawableRight图片
- Oracle查询1-12月数据
- ExpandableListView安卓开发可扩展的listview
- 堆排序算法
- JavaScript 学习摘要
- Jquery scroll 向下滚动到据顶部超过1000px时,回到顶部
- Python的Module和Package
- 快速掌握Lua 5.3 —— "Iterators"和"Generic for"
- 浏览器引擎