Android Textview动态改变drawable
2016-07-20 11:56
411 查看
做了也有好一会的开发,决定写些东西来记录自己开发中用到的一些小技术,有些是别人那里看到的,但是不记得转载链接,如有雷同,请见谅
TextView代码改变drawable的图片
TextView代码改变drawable的图片
<TextView android:id="@+id/tv_guanzhu" android:layout_alignParentRight="true" android:layout_alignTop="@+id/cv_head" android:layout_marginTop="15dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:drawablePadding="5dp" android:padding="5dp" android:layout_marginRight="10dp" android:textColor="@color/theam_color" android:background="@drawable/lcbf_tuijian_guanzhu" android:drawableLeft="@mipmap/lcbf_search_add" android:text="已关注" android:visibility="gone" />
改变这个drawableLeft的图片代码如下
Drawable adddrawable=Context.getResources().getDrawable(本地图片路径);
tv_guanzhu.setCompoundDrawablesRelativeWithIntrinsicBounds(adddrawable, null, null, null);
这样就能在通过代码控制显示的图片了。good~
相关文章推荐
- Android 游戏编程
- Edittext密码与显示状态切换
- android studio导入项目下载gradle-x.x.x-all.zip 放那个文件夹目录
- 完善继承HorizontalScrollView做的SlidingMenu
- ANDROID应用性能调优的技术点
- 关于APK瘦身值得分享的一些经验
- android ColorMatrix常用图像颜色矩阵处理效果
- Plugin is too old, please update to a more recent version错误
- 关于touch事件分发
- Android资源代码 源码 整理 Github开源项目下载地址
- Android view 详解(一)LayoutInflater
- 多段合并播放器方案(移动版)
- Android基于Pull方式解析xml的方法详解
- android事件分发机制解析(配流程图)
- 给 Android 开发者的 RxJava 详解
- Android APK反编译就这么简单 详解(附图)
- H5通过input直接调用android摄像头
- Android Studio如何导入工程
- Introduction to Android Espresso
- Android使用PullToRefresh实现上拉加载和下拉刷新效果的代码