Material 主题 Light.DarkActionBar 中的文字颜色不浅
Text color isn't ligth in Material Theme Light.DarkActionBar
我正在尝试使用 Material 设计 Light.DarkActionBar 主题自定义应用程序主题,但 actionBar 中的文本颜色为黑色。我尝试使用 textColorPrimary 将颜色更改为白色,但是当我这样做时,我的应用程序中的所有文本都更改为白色。
这是我的 values/styles:
<resources>
<!-- Inherit from the light Material Theme -->
<style name="MissaoCaronaTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">@color/amareloSecundario</item>
<!-- cor da barra -->
<item name="colorPrimary">@color/amareloPrimario</item>
<!-- Cor dos controles -->
<item name="colorAccent">@color/amareloPrimario</item>
</style>
</resources>
这是我的 values-v21/styles:
<resources>
<style name="MissaoCaronaTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimaryDark">@color/amareloSecundario</item>
<!-- cor da barra -->
<item name="android:colorPrimary">@color/amareloPrimario</item>
<!-- Cor dos controles -->
<item name="android:colorAccent">@color/amareloPrimario</item>
</style>
</resources>
这是我的 androidmanifest:
<application android:label="@string/ApplicationName" android:theme="@style/MissaoCaronaTheme"></application>
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Text Hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Text Hello" />
</LinearLayout>
这是我的 activity:
[Activity(Label = "Usuário")]
public class UsuarioEditView : MvxActivity<UsuarioViewModel>
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.UsuarioEditView);
}
}
维尼修斯,
您可以为 actionBar 中的文本创建特定样式,并将其仅用于此文本,而不是更改 textColorPrimary。
例如:
在styles.xml中:
<item name="colorTextActionBar">@color/branco</item>
在这种情况下,还要编辑 color.xml 文件:
<item name="branco" type="color">#FFFFFFFF</item>
因此,当您更改 textColorPrimary 时,它将影响整个应用程序主题,这意味着与此样式关联的所有组件都会受到影响。这就是为什么你所有的文字都变成了白色。
因此,您可以在选择中添加您选择的新颜色,而不是更改常用颜色。
您需要确保在 colors.xml 文件中也添加了相应的颜色。
在 styles.xml 中:
<item name:"nameOfYourChoice">@color/colorName</item>
并且在 colors.xml 中:
<color name="colorName">#colorValue</color>
确保正确编辑 xml 文件。
请初始化您的主题 activity 代码后的标签部分。
[Activity(Label = "Usuário", Theme = "@style/MissaoCaronaTheme", Icon = "@drawable/icon")]
我发现了问题。问题是来自 MvvmCross 框架的 MvxActivity。我不知道为什么,但是当我将 MvxActivity 与 material 设计一起使用时,ActionBar 的文本始终为黑色,而当我将 MvxAppCompatActivity 与 AppCompat 主题一起使用时,ActioBar 标题为白色。
我正在尝试使用 Material 设计 Light.DarkActionBar 主题自定义应用程序主题,但 actionBar 中的文本颜色为黑色。我尝试使用 textColorPrimary 将颜色更改为白色,但是当我这样做时,我的应用程序中的所有文本都更改为白色。
这是我的 values/styles:
<resources>
<!-- Inherit from the light Material Theme -->
<style name="MissaoCaronaTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimaryDark">@color/amareloSecundario</item>
<!-- cor da barra -->
<item name="colorPrimary">@color/amareloPrimario</item>
<!-- Cor dos controles -->
<item name="colorAccent">@color/amareloPrimario</item>
</style>
</resources>
这是我的 values-v21/styles:
<resources>
<style name="MissaoCaronaTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimaryDark">@color/amareloSecundario</item>
<!-- cor da barra -->
<item name="android:colorPrimary">@color/amareloPrimario</item>
<!-- Cor dos controles -->
<item name="android:colorAccent">@color/amareloPrimario</item>
</style>
</resources>
这是我的 androidmanifest:
<application android:label="@string/ApplicationName" android:theme="@style/MissaoCaronaTheme"></application>
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Text Hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="40dp"
local:MvxBind="Text Hello" />
</LinearLayout>
这是我的 activity:
[Activity(Label = "Usuário")]
public class UsuarioEditView : MvxActivity<UsuarioViewModel>
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.UsuarioEditView);
}
}
维尼修斯,
您可以为 actionBar 中的文本创建特定样式,并将其仅用于此文本,而不是更改 textColorPrimary。
例如:
在styles.xml中:
<item name="colorTextActionBar">@color/branco</item>
在这种情况下,还要编辑 color.xml 文件:
<item name="branco" type="color">#FFFFFFFF</item>
因此,当您更改 textColorPrimary 时,它将影响整个应用程序主题,这意味着与此样式关联的所有组件都会受到影响。这就是为什么你所有的文字都变成了白色。 因此,您可以在选择中添加您选择的新颜色,而不是更改常用颜色。 您需要确保在 colors.xml 文件中也添加了相应的颜色。
在 styles.xml 中:
<item name:"nameOfYourChoice">@color/colorName</item>
并且在 colors.xml 中:
<color name="colorName">#colorValue</color>
确保正确编辑 xml 文件。
请初始化您的主题 activity 代码后的标签部分。
[Activity(Label = "Usuário", Theme = "@style/MissaoCaronaTheme", Icon = "@drawable/icon")]
我发现了问题。问题是来自 MvvmCross 框架的 MvxActivity。我不知道为什么,但是当我将 MvxActivity 与 material 设计一起使用时,ActionBar 的文本始终为黑色,而当我将 MvxAppCompatActivity 与 AppCompat 主题一起使用时,ActioBar 标题为白色。