【问题标题】:How to Change the toolbar black color text into White in Xamarin.Android while retaining black text of activity text?如何在 Xamarin.Android 中将工具栏黑色文本更改为白色,同时保留活动文本的黑色文本?
【发布时间】:2015-06-19 06:13:48
【问题描述】:

我使用此代码在 xamarin.android 中创建了一个工具栏。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/android-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />

但是显示的文本颜色是黑色的,但我希望它是白色的。我的朋友让我这样做。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/android-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" 

app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

但它显示以下错误。

"No resource identifier found for attribute "theme" in package "android-auto"
"no resource identifier found for attribute "popupTheme" in package "android-auto"

你能推荐一些代码吗?

【问题讨论】:

    标签: android xamarin xamarin.android xamarin-studio


    【解决方案1】:

    认为您在此位使用了错误的包 app: 而不是 android:

    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    

    试试这个:

    <?xml version="1.0" encoding="utf-8"?>
    <Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com//apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?android:attr/actionBarSize"
        android:background="?android:attr/colorPrimary"
        android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar"
        android:popupTheme="@android:style/ThemeOverlay.Material.Light" />
    

    【讨论】:

    • 啊,将其更改为 local:theme 和 local:popupTheme 是否解决了您的问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    相关资源
    最近更新 更多