我正在处理的应用程序已经将主/暗/重音颜色设置为我想要的颜色,并且它们出现在正确的位置(正如预期的那样)。不过,我使用的是一种偏好活动,我希望我使用的preferenceswitch的颜色会以重音颜色呈现。相反,它们是以材质的颜色呈现出来的。我在想,Lollipop的这种默认行为,就像Kitkat中的蓝色吗?我甚至没有引用代码中任何地方都是#009688的颜色,也没有引用我的colors.xml / styles.xml。
colors.xml
<resources>
<color name="primary">#00BCD4</color>
<color name="primary_dark">#0097A7</color>
<color name="accent">#FFD740</color>
</resources>styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>有什么想法吗?我会提供更多的信息。我在这里看到了一些关于创建定制东西的东西,但这真的有必要吗?
preferenceActivity.java
public class PreferenceActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PrefFrag prefFragment = new PrefFrag();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(android.R.id.content, prefFragment);
fragmentTransaction.commit();
}
}发布于 2015-06-06 03:24:37
当您使用AppCompat时,您应该使用每个属性的非前缀版本--这可以确保它们在所有API级别上都可用(与android:级别不同,后者仅适用于API21+ ):
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>https://stackoverflow.com/questions/30674904
复制相似问题