android - setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)不起作用

标签 android xml graphics android-edittext android-drawable

我有几个 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/

相关文章:

c++ - 插值噪声中的伪影

c++ - 如何在 Raylib 中用像素追踪路径?

android - 具有不同上下文的共享偏好

Android XML 序列化

C# 如何对内存对象执行实时 xslt 转换?

html - Bootstrap 导航栏调整大小

android - 如何在 Google map 上放置图钉以及如何在 Google map 上的对话框中获取当前地址?

java - 如何从 java 类中读取内容?

android - 通知中的音乐播放器控制

regex - 如何从 XSLT 2.0 中的字符串中选择特定部分