android - How do I set up an icon (drawable) for a button in anko? -


i want have icon in centre of plain button, using anko. tried

button.backgroundresource = r.drawable.arrow_forward

but got drawable covering whole button , getting background colour parent (setting background colour on button explicite nothing).

enter image description here

i tried drawable = ... well, same effect. how set icon anko have original aspect ratio , centered?

first off, in order set icon/iamge on button should use imagebutton.

then it's easy.

imagebutton{ imageresource = r.drawable.ic_cc_checkmark }

if need use other resources or drawable, without getting resource not found error use ctx.getdrawable(r.x.y)

hope helps someone


Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -