How to add image for button in android?

前端 未结 9 1240
再見小時候
再見小時候 2021-02-02 06:44

How can I add an image to a button, rather than text?

9条回答
  •  眼角桃花
    2021-02-02 07:31

    As he stated, used the ImageButton widget. Copy your image file within the Res/drawable/ directory of your project. While in XML simply go into the graphic representation (for simplicity) of your XML file and click on your ImageButton widget that you added, go to its properties sheet and click on the [...] in the src: field. Simply navigate to your image file. Also, make sure you're using a proper format; I tend to stick with .png files for my own reasons, but they work.

提交回复
热议问题