1 . 如果想手動(dòng)設(shè)置大小的話就要用setCompoundDrawables抑党,事先要給Drawable設(shè)置setBounds新荤。
例子:
Resources res = TabTest.this.getResources();
Drawable myImage = res.getDrawable(R.drawable.home);
myImage.setBounds(1, 1, 100, 100);
button.setCompoundDrawables(null, myImage, null, null);
- 如果按照原有比例大小顯示圖片就使用setCompoundDrawablesWithIntrinsicBounds
例子:
button = (RadioButton) group.getChildAt(i);
Resources res = TabTest.this.getResources();
Drawable myImage = res.getDrawable(R.drawable.home);
button.setCompoundDrawablesWithIntrinsicBounds(null, myImage, null, null);