Switchcompat不显示的切换 [英] Switchcompat not displaying the Switch
问题描述
我想使用最新的appcompat这是更新的材料设计在我的应用程序,以显示切换视图显示在棒棒糖(<一href="http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-$p$p.html">http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-$p$p.html),是切换是没有得到显示问题我SDKmin是14,最大是21,我现在用的是低于code的布局:
&LT; LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
机器人:ID =@ + ID / fragment_scheduler
工具:上下文=com.stackoverflow.ranjith.androidprojdel.SchedulerUI&GT;
&LT; android.support.v7.widget.SwitchCompat
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=开关
应用程序:showText =FALSE/&GT;
&LT;按钮
机器人:layout_width =match_parent
机器人:文本=开始
机器人:ID =@ + ID /启动
机器人:layout_height =WRAP_CONTENT/&GT;
&LT; / LinearLayout中&GT;
Build.gradle:
相关性{
编译com.android.support:cardview-v7:+
编译com.android.support:recyclerview-v7:+
编译com.android.support:palette-v7:+
编译com.android.support:support-v4:+
编译com.android.support:appcompat-v7:21.0.+
编译文件树(导演:库,包括:['的* .jar'])
}
今天我同样的问题,但不知何故,在我的样本switchcompat工作。我认为有问题的应用程序的风格,它的父应设置为:
Theme.AppCompat
I am trying to use the latest appcompat which was updated for material design in my app to show the switch view as displayed in Lollipop(http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html), the problem is the switch is not getting displayed. My SDKmin is 14 and max is 21. I am using the below code in the layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/fragment_scheduler"
tools:context="com.stackoverflow.ranjith.androidprojdel.SchedulerUI">
<android.support.v7.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="switch"
app:showText="false" />
<Button
android:layout_width="match_parent"
android:text="start"
android:id="@+id/start"
android:layout_height="wrap_content" />
</LinearLayout>
Build.gradle:
dependencies {
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:support-v4:+'
compile "com.android.support:appcompat-v7:21.0.+"
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I had same problem today but somehow it switchcompat worked in my sample. I think that there is problem with app style, it parent should be set to:
Theme.AppCompat
这篇关于Switchcompat不显示的切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!