我有几个 EditText View
,我想在其中设置左侧的图像,而 setCompoundDrawablesWithIntrinsicBounds
似乎不起作用。图形似乎没有改变。
有人知道为什么会这样吗?
这是我设置可绘制对象的方式:
mFirstname.setCompoundDrawablesWithIntrinsicBounds(R.drawable.user_icon, 0, 0, 0);
mLastname.setCompoundDrawablesWithIntrinsicBounds(R.drawable.user_icon, 0, 0, 0);
mEmail.setCompoundDrawablesWithIntrinsicBounds(R.drawable.mailicon, 0, 0, 0);
mPassword.setCompoundDrawablesWithIntrinsicBounds(R.drawable.lockicon, 0, 0, 0);
mDateOfBirth.setCompoundDrawablesWithIntrinsicBounds(R.drawable.calico, 0, 0, 0);
mCity.setCompoundDrawablesWithIntrinsicBounds(R.drawable.mailicon, 0, 0, 0);
mStreet.setCompoundDrawablesWithIntrinsicBounds(R.drawable.mailicon, 0, 0, 0);
mPostcode.setCompoundDrawablesWithIntrinsicBounds(R.drawable.mailicon, 0, 0, 0);
mPhoneNumber.setCompoundDrawablesWithIntrinsicBounds(R.drawable.mailicon, 0, 0, 0);
最佳答案
如果其他人遇到这个看似无法解释的问题,请尝试以下操作:
- 转到您的 XML 模板。
- 删除表示它的 XML 图像。
- 您的 View 应该刷新 compounddrawable。
基本上这部分 View 似乎不会在 ICS 设备上重新膨胀。希望这可以解决某些人的问题!
关于android - setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20423445/