1

enter image description here

Output is like Above right now... Not showing SWITCH ..shows only On/Off

This is my Code for Switch...

all other device Output is Good but in NExus 5 it shows on/off only not a switch/toggel.

<LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="0.7"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="5dp"
                        android:text="Save recorded call? "
                        android:textColor="@color/black"
                        android:textStyle="bold" />

                    <Switch
                        android:id="@+id/recSwitch"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textOff="Off"
                        android:textOn="On" />
                </LinearLayout>

Thank you in advance for the help.. suggestions acceptable..

Rajesh Satvara
  • 3,842
  • 2
  • 30
  • 50
  • use [switchCompat](https://developer.android.com/reference/android/support/v7/widget/SwitchCompat.html) instead of switch – SaravInfern Aug 10 '16 at 10:38

1 Answers1

1

Add in your dependency

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.3'
}

In your xml

<LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="0.7"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="5dp"
                    android:text="Save recorded call? "
                    android:textColor="@color/black"
                    android:textStyle="bold" />

                <android.support.v7.widget.SwitchCompat
                     android:id="@+id/switch_compat2"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="Switch Compat"
                     app:showText="false"/>
            </LinearLayout>
SaravInfern
  • 3,338
  • 1
  • 20
  • 44