Android: Button with two images | alignment -
i have created button programmatically , able set icon on using below code
drawable icon = context.getresources().getdrawable(iconresourceid); button.setcompounddrawableswithintrinsicbounds(icon, null, null, null); now, want have image (icon) on right top corner, please see below image:
i have tried add both images, using below code:
drawable icon = context.getresources().getdrawable(iconresourceid); drawable icon2 = context.getresources().getdrawable(iconresourceid2); button.setcompounddrawableswithintrinsicbounds(icon, null, icon2, null); and, getting below results:
can please tell me, how can align right top corner?
your code btn_background background have @ moment
button button = new button(this); drawable icon = context.getresources().getdrawable(iconresourceid); button.setcompounddrawableswithintrinsicbounds(icon, null, null, null); button.settext("test"); if (hasnewupdates()) { button.setbackgroundresource(r.drawable.btn_background_with_icon); } else { button.setbackgroundresource(r.drawable.btn_background); } and how btn_background_with_icon like
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/btn_background"/> <item android:gravity="right" android:bottom="72dp" android:drawable="@drawable/ico_info"/> </layer-list> 


Comments
Post a Comment