TextView使用drawable属性
来源:互联网 发布:五星体育网络源 编辑:程序博客网 时间:2024/05/22 08:02
想实现文本加图片效果,可以使用drawab属性可以实现
代码实现:
drawable = getResources().getDrawable(R.mipmap.ic_launcher);
/*这一步必须要做,否则不会显示./
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());//对图片进行压缩
/*设置图片位置,四个参数分别方位是左上右下,都设置为null就表示不显示图片/
edSearch.setCompoundDrawables(drawable, null, drawable, null);
Xml实现:
android:drawableLeft=”@mipmap/ic_launcher”
android:drawablePadding=”@dimen/margin_8”
android:drawableRight=”@mipmap/ic_launcher”
Drawable新属性:
edSearch.setCompoundDrawablesWithIntrinsicBounds(drawable, null, drawable, null); 可以替换 drawable = getResources().getDrawable(R.mipmap.ic_launcher); /**这一步必须要做,否则不会显示.*/ drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());//对图片进行压缩 /**设置图片位置,四个参数分别方位是左上右下,都设置为null就表示不显示图片*/ edSearch.setCompoundDrawables(drawable, null, drawable, null);
阅读全文
1 0
- TextView使用drawable属性
- TextView的drawable属性
- Android布局技巧:使用TextView的drawable属性
- 动态设置TextView的drawable属性
- Android笔记之TextView中使用Drawable
- TextView属性的简单使用
- drawable属性
- 为TextView添加Drawable
- TextView设置drawable
- TextView设置drawable
- 使用IB时设置textView属性崩溃
- 简述关于TextView的属性使用
- textview属性
- TextView属性
- TextView属性
- textview 属性
- TextView属性
- textview 属性
- UGUI学习笔记(五) ToggleGroup制作选择题单选框
- YOLO 图解
- 334. Increasing Triplet Subsequence
- 2017 年你应该尝试的 25 个 Android 库
- Android解决不同分辨率距离一致的问题
- TextView使用drawable属性
- Fountains CodeForces
- 抽象类与接口的区别
- 423. Reconstruct Original Digits from English
- 一个简单的SpringMVC框架web程序
- 4. Median of Two Sorted Arrays
- “System.StackOverflowException”类型的未经处理的异常在 App_Code.qcryqgiv.dll 中发生
- javascript中的define用法
- 447. Number of Boomerangs