我創造了這個按鈕編程,我能夠通過使用下面的代碼來設置上的icon
Android:帶有兩個圖像的按鈕|對準
Drawable icon = context.getResources().getDrawable(iconResourceId);
button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
現在,我要對右上方另一個圖像(icon
)角落,請參見下面的圖片:
我曾嘗試使用下面的代碼添加兩個圖像, :
Drawable icon = context.getResources().getDrawable(iconResourceId);
Drawable icon2 = context.getResources().getDrawable(iconResourceId2);
button.setCompoundDrawablesWithIntrinsicBounds(icon, null, icon2, null);
和,我得到下面的結果:
誰能告訴我,我該如何調整它的右上角?
嘗試使用按鈕和設置相對的ImageView Image to imagview –
RelativeLayout將執行該操作 –
在xml中創建一個包含按鈕背景和頂部新圖標的層列表。將該層列表設置爲您的按鈕背景 –