Prabhuraj
Prabhuraj

Reputation: 928

ToggleButton per Lollipop

I want my ToggleButton to like like this . Toggle as in Lollipop

But with this code , it always shows me the older toggle button. enter image description here

Am running the code in Emulator with API 21 only, Am I missing something here. My code snippet is

   <ToggleButton

            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

Upvotes: 0

Views: 2051

Answers (3)

Nivedh
Nivedh

Reputation: 961

Use Switch instead of toggle button you will get what u need. No need for external libraries

Upvotes: 0

Prabhuraj
Prabhuraj

Reputation: 928

Found a solution.

Using Android support library. Code snippet is..

<android.support.v7.widget.SwitchCompat
            android:id="@+id/id_useridview_switch"
            android:layout_marginTop="24dp"
            android:layout_width="wrap_content"
            android:layout_height="2dp"
            android:theme="@style/colortoggle"
            />

Thanks Selvin, got a clue from ur and on what to search

Upvotes: 6

DEON
DEON

Reputation: 3

In this code you just set the width and height of your toggle button! for Android L toggle button you should use support libraries to achieve that! google something like these:

android L Toggle button support libraries Also search in Github.com

Upvotes: 0

Related Questions