0

I am working on an Android app in which I want to have a SwitchCompat with a drawable shown between the switch text and the switch toggle view as shown below.

Intended switch

For that, I thought android:drawableEnd would work fine, but contrary to my expectations, it places the drawable to the end of the switch toggle as shown below.

Actual switch

Is there any way I can achieve this effect except for showing the drawable between a separate TextView for the text and a separate SwitchCompat for the toggle?

Abdul Mateen
  • 1,418
  • 1
  • 14
  • 32
  • 1
    you could use textview, and a imageview and a switchcompact in a linearlayout. drawableEnd works as expected. – Raghunandan Feb 04 '20 at 07:14
  • Yes, this is a possible workaround. Thanks! – Abdul Mateen Feb 04 '20 at 07:34
  • 1
    or you would need to extend a compound button yourself and style them and draw the components you need which is a lot of work. I tried extending switchcompact but not all api's are exposed public so you would have to draw a custom view yourself by measuring and doing all calculations yourself. – Raghunandan Feb 04 '20 at 07:36
  • Yeah exactly. This is a lot of extra work for something that is not as demanding. Could you please write out all this into an answer so that I can accept it and close this loop? – Abdul Mateen Feb 04 '20 at 08:27

0 Answers0