When I am add icon like below:
etComment = (EditText) findViewById(R.id.et_comment);
Drawable img = getResources().getDrawable( R.drawable.warning );
etComme
I've found the solution in this post.
Drawable dr = this.getResources().getDrawable(R.drawable.warning);
Bitmap bitmap = ((BitmapDrawable) dr).getBitmap();
Drawable d = new BitmapDrawable(this.getResources(), Bitmap.createScaledBitmap(bitmap, 35, 35, true));
txtValue.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
HTH, Milton
I think you can use different size of pics for different screens and use getMinimumWidth to set Bounds.But I did not try it before , may be it is not appropriate for .9 patch.
When you use setCompoundDrawables , you need code like :
Drawable img;
Resources res = getResources();
img = res.getDrawable(R.drawable.btn_img);
//You need to setBounds before setCompoundDrawables , or it couldn't display
img.setBounds(0, 0, img.getMinimumWidth(), img.getMinimumHeight());
btn.setCompoundDrawables(img_off, null, null, null);
Use setCompoundDrawables() instead of setCompoundDrawablesWithIntrinsicBounds() - you'll have to set the bounds of the drawables manually.