Android: Button with two images | alignment

Viewed 387

I have created this button programmatically and I am able to set the icon on the by using below code

enter image description here

Drawable icon = context.getResources().getDrawable(iconResourceId);
button.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);

Now, I want to have another image (icon) on the right top corner, please see the below image:

enter image description here

I have tried to add both images, by using below code:

Drawable icon = context.getResources().getDrawable(iconResourceId);
Drawable icon2 = context.getResources().getDrawable(iconResourceId2);
button.setCompoundDrawablesWithIntrinsicBounds(icon, null, icon2, null);

and, I am getting below results:

enter image description here

Can anyone please tell me, how can I align it to the right top corner?

1 Answers
Related