Search code examples
androidbuttontextviewshow-hideindicator

Android - Show/Hide indicator next to TextView or Button


I have some buttons/textviews which when clicked, some layouts are shown or hidden. I want to add a show/hide indicator at the left of these buttons/textviews but I can't seem to find a way. I tried using text characters like ( ▼ )programmatically but I get a message from Eclipse about character encoding. (plus it's not a very visually elegant solution). The ideal would be something like this. which is offered by the Expandable ListView. How can I make a textview or button have a style like this?

expandable listView indicator


Solution

  • Use an ImageView, there are official icon packs where you can find an ic_action_collapse.png and ic_action_expand.

    (You can find in them in the folders 02_navigation_expand and 02_navigation_collapse) in dark and light and the 4 resolution variants (mdpi, hdpi, xhdpi and xxhdpi).

    Just copy the directories into your res folder and the correct resolution will be picked by android automaticall.