ida
ida

Reputation: 545

How to set the text for custom made toggle button android

custom toggle button

how to add the text "on" & "off" for the toggle button ? Do we need to add text also in image ?

Upvotes: 1

Views: 1454

Answers (2)

user3062390
user3062390

Reputation: 26

If you are using XML to generate the toggle button you would use android:textOn and android:textOff in your ToggleButton<>

Source: http://developer.android.com/reference/android/widget/ToggleButton.html#attr_android:textOn

Upvotes: 0

Peri Hartman
Peri Hartman

Reputation: 19474

You have a few options.

  1. Make your graphic larger and include the text.
  2. Use a LinearLayout and incorporate two TextViews around your ImageView.
  3. Subclass your overall view and draw the text in onDraw().

Upvotes: 2

Related Questions