removing whitespace in android Switch which is devoted to text


(we all know) There are three parts in android Switch Widget ... Text - Thumb - Track.<br /> 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 <br /><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/vJ9Av.png" data-original="https://i.stack.imgur.com/vJ9Av.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


You simply have to not provide any text:

<Switch android:id="@+id/switch1" android:layout_width="wrap_content" android:layout_height="wrap_content" />


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.


  • How to use CSS on an Html.ActionLink in C#
  • Avoiding image upload on a refresh
  • Accessing types defined inside package from java
  • How to join two tables and map the result to a case class in slick
  • How to get elements with a unique number from a json array in PostgreSQL?
  • How to manage state in JAX-RS?
  • Generic classes with Collection getter of other types
  • Why does the font in these TD elements render at different sizes?
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • Accessing Rows In A LINQ Result Without A Foreach Loop?
  • What is the correct way to synchronize a shared, static object in Java?
  • Yii2: Finding file and getting path in a directory tree
  • WPF version of .ScaleControl?
  • Android Activity.onWindowFocusChanged doesn't get called from within TabHost
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Zurb Foundation _global.scss meta styles for js?
  • What is Eclipse's Declaration View used for?
  • Javascript Callbacks with Object constructor
  • MySQL WHERE-condition in procedure ignored
  • Join two tables and save into third-sql
  • How can I use Kendo UI with Razor?
  • How to make Safari send if-modified-since header?
  • Web-crawler for facebook in python
  • Jquery - Jquery Wysiwyg return html as a string
  • align graphs with different xlab
  • SVN: Merging two branches together
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • trying to dynamically update Highchart column chart but series undefined
  • How to stop GridView from loading again when I press back button?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Append folder name and increment by 1 using batch script
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize