When I am add icon like below:
etComment = (EditText) findViewById(R.id.et_comment);
Drawable img = getResources().getDrawable( R.drawable.warning );
etComment.setCompoundDrawablesWithIntrinsicBounds( img, null, null, null );
The icon resizes EditText. How can I calculate img size and put it into EditText without EditText resize?
Thanks!
FunkTheMonk
Use setCompounDrawables() instead of setCompoundDrawablesWithIntrinsicBounds() - you'll have to set the bounds of the drawables manually.
I don't understand how to calculate Bounds manually. I have got height and width of EditText:
etComment = (EditText) findViewById(R.id.et_comment);
Drawable img = getResources().getDrawable( R.drawable.warning );
int size = etComment.getHeight();
img.setBounds(0, 0, size, size);
etComment.setCompoundDrawables( img, null, null, null );
but I have different results in different screen sizes. How I can calculate correct size and padding of icon? Could you please help me?