I have a few EditText views
where I want to set the image on the left and setCompoundDrawablesWithIntrinsicBounds
does not seems to be working. The graphics do not seem to be getting changed.
does anyone know why this might be the case?
Here is how I am setting the drawables:
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);
If anyone else has this seemingly unexplainable issue then try the following:
basically this portion of the view does not seem to get reinflated on ICS devices. Hopefully this solves the problem for some people!
Another solution is to setup compound drawable on the next (after layout) cycle of the UI loop:
final TextView viewById = (TextView) findViewById(R.id.label);
viewById.post(new Runnable()
{
@Override
public void run()
{
viewById.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_call, 0, 0, 0);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With