【发布时间】:2014-10-25 15:23:54
【问题描述】:
我正在尝试使用为我的应用程序中的材料设计更新的最新 appcompat 来显示在 Lollipop(http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html) 中显示的开关视图,问题是开关没有显示。我的 SDKmin 为 14,max 为 21。我在布局中使用以下代码:
<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'])
}
【问题讨论】:
-
这是整个布局吗? SwitchCompat 被添加到哪个视图?
-
不..布局中还有按钮。它在线性布局内。我已经添加了整个布局
-
对如何让它发挥作用有什么看法吗?
-
尝试删除
app:showText="false"并使用android:text="" -
这不起作用..
标签: android android-5.0-lollipop android-appcompat