我想让我的应用有一个棒棒糖风格的切换按钮:
我如何实现这个按钮,让它在旧版本的android上看起来也是这样的?
发布于 2015-08-26 11:48:40
要在旧版本的安卓上使用棒棒糖样式切换按钮,你应该在布局xml文件中使用SwitchCompat
<android.support.v7.widget.SwitchCompat
android:id="@+id/compatSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
也在java文件中。
SwitchCompat switchCompat = (SwitchCompat) findViewById(R.id.compatSwitch);
发布于 2015-04-20 15:42:17
安卓开发者博客上有一篇很棒的文章,讨论了如何在棒棒糖之前的设备上使用材料设计:http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html
为了更具体地回答您的问题,您可以通过使用SwitchCompat
API:https://developer.android.com/reference/android/support/v7/widget/SwitchCompat.html在旧版本中使用棒棒糖样式开关。
发布于 2016-07-18 04:47:44
API 24 on off开关
<android.support.v7.widget.SwitchCompat
android:id="@+id/switch1"
android:layout_alignBottom="@+id/textView3"
android:layout_alignEnd="@+id/input_layout_password"
android:layout_alignRight="@+id/input_layout_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
https://stackoverflow.com/questions/29752235
复制