组件设置setCompoundDrawables不生效解决办法
来源:互联网 发布:mac子弹头口红价格 编辑:程序博客网 时间:2024/05/21 04:25
组件设置setCompoundDrawables
不生效解决办法
在代码中设置组件的drawable的时候如果单纯的使用setCompoundDrawables
是不会有效果的,因为没有指定drawable的大小,即Bound
,具体代码如下:
Drawable drawable = getResources().getDrawable(R.drawable.ic_et_bg);drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());mEt.setCompoundDrawables(mEt.getCompoundDrawables()[0],drawable,mEt.getCompoundDrawables()[2],mEt.getCompoundDrawables()[0]);
这种方式是可以指定drawable的大小的,还有另外一种方式,使用drawable的默认大小,如下:
Drawable drawable = getResources().getDrawable(R.drawable.ic_et_bg);mEt.setCompoundDrawablesWithIntrinsicBounds(mEt.getCompoundDrawables()[0],drawable,mEt.getCompoundDrawables()[2],mEt.getCompoundDrawables()[0]);
0 0
- 组件设置setCompoundDrawables不生效解决办法
- iptables不生效解决办法
- .bash_profile不生效解决办法
- raidiusTopLeft不生效解决办法
- 关于极光IM设置昵称不生效的解决办法
- 环境变量设置后不生效
- 设置状态栏颜色不生效
- raido设置选中不生效
- TextView setCompoundDrawables不显示
- setCompoundDrawables不显示图片
- setCompoundDrawables不显示图片
- 微信小程序-page.json中设置背景色不生效解决办法
- SpannableString同时设置ClickableSpan和ForegroundColorSpan时ForegroundColorSpan不生效的解决办法
- 微信小程序---app.json中设置背景色不生效解决办法
- host 配置不生效的解决办法
- win7 32 jadclipse 不生效解决办法
- host 配置不生效的解决办法
- ListView的setOnItemClickListener不生效的解决办法
- 笔记
- Android Studio 多渠道打包之友盟打包
- Jquery操作元素
- 带有清空功能的EditTtxt
- KVM配置实现跨网段通信
- 组件设置setCompoundDrawables不生效解决办法
- NOIP必备知识——学习清单
- import cv2 报错 Segmentation fault (core dumped)
- 配置Log4j
- 微信小程序—下拉刷新上拉加载
- 获取组件当中某个Drawable所在的坐标范围
- POJ - 1185 炮兵阵地
- [Leetcode] Remove Duplicates from Sorted List II
- LeetCode-476. Number Complement-思路详解-C++