I created this button programmatically, and I can install iconon this using the code below

Drawable icon = context.getResources().getDrawable(iconResourceId);
button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
Now, I want to have another image ( icon) in the upper right corner, see the image below:

I tried to add both images using the code below:
Drawable icon = context.getResources().getDrawable(iconResourceId);
Drawable icon2 = context.getResources().getDrawable(iconResourceId2);
button.setCompoundDrawablesWithIntrinsicBounds(icon, null, icon2, null);
and, I get below results:

Can someone tell me how I can align it in the upper right corner?
source
share