我创建了一个首选项活动,并在样式.xml中为它设置了一个样式,包括常规版本和v21版本的文件。配色方案是默认的,但在样式中我将强调色更改为橙色......这在AndroidStudio模拟器上效果很好。
但是,当我在手机(Galaxy s6)上安装apk时,不使用橙色,通常整个布局看起来与模拟器上的默认布局不同,然后再将主题色更改为橙色。
这是为什么呢?我是否需要更改某些内容,以便我在Android Studio上自定义的样式/主题也适用于设备?
我的风格:
<style name="PreferenceTheme">
<!-- Customize your theme here. -->
<item name="android:colorAccent">@color/laborswipe_orange</item>
<item name="android:textColorHighlight">@color/laborswipe_orange</item>
</style>
我在 AndroidManifest 中的偏好活动:
<activity
android:name=".ProfileActivity"
android:label="@string/title_activity_profile"
android:theme="@style/PreferenceTheme"></activity>
提前感谢您的帮助!
PreferenceTheme 没有父级。还要检查您是否按预期覆盖此标记内的颜色。在样式中尝试此操作.xml:
<style name="PreferenceTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="android:colorAccent">@color/laborswipe_orange</item>
<item name="android:textColorHighlight">@color/laborswipe_orange</item>
</style>
还要检查 ide 是否在运行时连接到模拟器,并且没有挂起"等待设备联机"。在这种情况下 - 检查Android版本是否匹配Grandle Script build.gradle的minSdkVersion
和targetSdkVersion
以及模拟器设备。检查这些版本是否支持主题。