V
V
Vladislav2015-11-07 18:23:48
Android
Vladislav, 2015-11-07 18:23:48

How to make a button with a picture and text in android?

How can I make a button and a picture next to it, for example, as in the VK or Instagram application.
I did this:
1) took a picture from here PNG : https://www.google.com/design/icons/
2) created a regular Button in a LinearLayout
3) Set it to text, padding, drawableLeft: myPng
seems to be nothing and even looks good , now there is a problem
Google seems to say that these pictures can change color:
That is, I can make it so that after clicking on this button, it turns red like in Instagram. like button (I like it)
PS Perhaps you can even give some advice on how to write this correctly. Or are there repositories open for similar applications

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Yakushev, 2015-11-07
@VYakushev

Google seems to have quite clearly written how to add pictures to a button: developer.android.com/intl/ru/guide/topics/ui/cont... If we talk about a button that changes its appearance depending on the state, then I It seems that here you need to modify the appearance of the Checkbox. I think this option will help you: stackoverflow.com/questions/3192173/change-icons-o...

T
Tiberal, 2015-11-09
@Tiberal

We need a selector, Carl! You make two layer_list one for the pressed state with one picture, the other for the normal state. From all this you peel the selector, and assign buttons to the background.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question