我创造了这个按钮编程,我能够通过使用下面的代码来设置上的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中创建一个包含按钮背景和顶部新图标的层列表。将该层列表设置为您的按钮背景 –