我正在尝试使用最新的appcompat,这是更新的材料设计在我的应用程序,以显示开关视图显示在洛利波普(http://android-developers.blogspot.in/2014/10/appcompat-v21-material-design-for-pre.html),问题是开关没有被显示。我的SDKmin是14,最大值是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'])
}发布于 2014-11-05 22:19:19
我今天也有同样的问题,但是它在我的样本中起了作用。我认为应用程序的样式有问题,应该将它的父级设置为:
Theme.AppCompat发布于 2014-12-16 21:47:34
我不确定这是否是支持库中的一个bug,但是您必须确保布局充气器的上下文是主题的。
发布于 2017-10-04 17:07:52
或者,您也可以利用
android:theme="@style/Theme.AppCompat"
在你的控制下
https://stackoverflow.com/questions/26563986
复制相似问题