我正在开发的应用程序我已将主色/深色/强调色设置为我想要的颜色,并且它们出现在正确的位置(如预期)。我有一个我正在使用的偏好活动,我希望该活动的颜色preferenceswitch
我正在使用的 会以强调色呈现。相反,它们以材质青色呈现。我想知道 Lollipop 的默认行为是不是像 Kitkat 中的蓝色一样?我什至没有提到颜色#009688
我的代码或我的任何地方colors.xml
/ styles.xml
.
颜色.xml
<resources>
<color name="primary">#00BCD4</color>
<color name="primary_dark">#0097A7</color>
<color name="accent">#FFD740</color>
</resources>
样式.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>
有任何想法吗?我将提供更多信息。我在这里看到了一些关于创建自定义内容的内容,但这真的有必要吗?
偏好活动.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();
}
}
当你使用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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)