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

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -