Inflate the look of the button?

I have seen these questions unanswered in some forums and am wondering if anyone has a clue on how to answer.

Say, for example, a button is needed with an image and text. It seems natural to create an xml view and then inflate it in Button. Is it possible?

At the moment, I don’t need the button to look like a mouse click or change color when I click, but it may also be interesting to consider how this will affect the creation of oversize.

Btw, I found this one tutorial describing a solution to the same problem, but they write a class extending the View to achieve the goal. This seems a bit redundant to me. http://kahdev.wordpress.com/2008/09/13/making-a-custom-android-button-using-a-custom-view/

Thanks in advance! Anna

0
source share
1 answer

Make an XML layout of your custom button containing TextView and ImageView. Place the following attributes in the root directory file:

android:background="@android:drawable/btn_default"
android:focusable="true"
android:clickable="true"

and you will get what you need.

0
source

Source: https://habr.com/ru/post/1754181/


All Articles