(we all know) There are three parts in android Switch Widget ... Text - Thumb - Track.
My question is how can we completely remove this text part if we don't want to use any text
because it's ruining the balance of the layout
Asked
Active
Viewed 323 times
0

Bryan Herbst
- 66,602
- 10
- 133
- 120

9patchcoder
- 619
- 1
- 5
- 17
2 Answers
0
You simply have to not provide any text:
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

Simon Marquis
- 7,248
- 1
- 28
- 43
0
Use negative margin for the switch as follows and see if it works:
<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="-10dp" />
I know some people consider it a bad practice to use negative margin but right it seems to be the easiest way.
You can set margin programmatically as well based on device type.

rupesh jain
- 3,410
- 1
- 14
- 22
-
It is bad practice with a capital B ! But since we're talking android here I think we understand each other Still ... since I'm going to support different screen sizes I cant use hardcoded margin – 9patchcoder Aug 13 '14 at 19:23