我在我的 Android 应用程序中使用了新的工具栏。我想要像“Light.DarkActionBar”一样的行为主题。所以我的内容背景是白色的。文本等是黑色的。我的 ActionBar/Toolbar 有自定义背景,还有白色文本和溢出菜单。 所以我在我的 styles.xml 中实现了这些:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/accentColor</item>
<item name="colorAccent">@color/accentColor</item>
</style>
工具栏的实现就像这样:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/primaryColor"
app:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
但看起来不像是想要的。工具栏文本和工具栏后退按钮 (getSupportActionBar().setDisplayHomeAsUpEnabled(true)
) 看起来仍然是黑色!!!
想我做错了吗?
最佳答案
好的,我找到了这个错误。
xmls:app
命名空间有错误的 URI。这是
xmlns:app="http://schemas.android.com/tools"
无论出于何种原因... 我把它改成了正确的:
xmls:app="http://schemas.android.com/apk/res-auto"
现在它像我想要的那样工作。
关于安卓工具栏 : Light. DarkActionBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26586024/