2015-06-29 26 views

回答

0

您可以使用setCompoundDrawablesWithIntrinsicBounds,因爲RadioButton是TextView的子類。例如。

radioButton.setCompoundDrawablesWithIntrinsicBounds (0, R.drawable.your_drawable_selector, 0, 0)

如果你有一個位圖,你可以使用

Drawable drawable = new BitmapDrawable(getResources(), yourBitmap); 
radioButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null); 

從文檔

設置可繪製(如果有的話)出現的,上面左邊,的 權,並在文本下面。如果您不想在此處繪製可繪製的 ,請使用0。 Drawables的邊界將被設置爲它們的內在邊界。

+0

如果我有位圖,該怎麼辦? –

+0

我編輯我的答案 – Blackbelt

+0

多數民衆贊成在工作不正常,我只是嘗試,然後我得到了錯誤「方法radioButtonsetCompoundDrawablesWithIntrinsicBounds(null,Drawable,null,null)是未定義的類型RadioButton」 –

相關問題