请快速提问。 我只是按照教程说明了在使用Material Design时如何更改工具栏和系统栏的颜色。 当在v21 / styles.xml中使用新颜色时,他们将它们称为colorPrimary和colorPrimaryDark,所以我得出结论第一个是工具栏,第二个是系统栏。我相信这是正确的,好像我用另一个名字取代其中一个,Android尖叫。 我们可以自定义更多的东西吗?这些项目的名单是否在某处?我一直在寻找,但到目前为止还不成功 干杯
答案 0 :(得分:1)
您可能希望看一下here。它为您提供了所有可用参数的列表。
如果您正在使用AppCompat,只需使用不带android前缀的属性,所以
<item name="android:colorPrimary">@color/primary</item>
将替换为
<item name="colorPrimary">@color/primary</item>
答案 1 :(得分:1)
你应该这样跟着 在VALUES v21中
style.xml
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
</style>
值 style.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/ColorPrimary</item>
<item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
</style>
color.xml
<color name="ColorPrimary">#ffffff</color>
<color name="ColorPrimaryDark">#d1d1d1</color>
布局
添加此
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/ColorPrimary"
android:id="@+id/actionbar"
android:theme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp">
</android.support.v7.widget.Toolbar>
最后一步是在你的Activity.java
中添加这一行 // calling android.support.v7.widget.Toolbar in ActionBar
setSupportActionBar((Toolbar) findViewById(R.id.actionbar));