2015-05-29 120 views
0

我想我的ToggleButton喜歡這樣。 Toggle as in Lollipop每個棒棒糖的ToggleButton

但使用此代碼,它總是顯示我舊的切換按鈕。 enter image description here

我只在API模擬器中運行代碼,我在這裏丟失了些什麼。我的代碼片段是

<ToggleButton 

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

*我在這裏丟失了什麼*是的,從android的世界的新聞...如appcompat庫... – Selvin

回答

0

在此代碼中,您只需設置切換按鈕的寬度和高度! 對於Android L切換按鈕,您應該使用支持庫來實現這一點! 谷歌的類似:

Android L移動切換按鈕支持庫 也搜索在Github.com

+1

謝謝DEON,你的答案幫助找出它 – Prabhuraj

6

找到了解決辦法。

使用Android支持庫。代碼段是..

<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" 
      /> 

感謝Selvin,得到了UR線索和什麼搜索

0

使用交換機而不是切換按鈕,你會得到什麼ü需要。不需要外部庫