安卓工具栏 : Light. DarkActionBar

标签 android android-actionbar android-toolbar

我在我的 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/

相关文章:

java - 是否可以将 FragmentActivity 放入 fragment 容器中?

Android - 如何以编程方式获取 parentActivityName 属性值?

android - 数据绑定(bind)中看不到工具栏

android - 无法导入 firebase auth android

android - 如何在以编程方式添加到 LinearLayout 的按钮之间添加边距空间?

android - 如何在 Android 中实现这种类型的底部表单对话框?

带有扩展工具栏的 Android Material

javascript - 在 android 浏览器中播放 html5 音频

带有主页按钮的android自定义操作栏 View

android - 知道为什么 Material 设计 "home up"按钮在旋转后会变黑吗?