3

I'm trying to custom App Theme using Material Design Light.DarkActionBar theme, but the text color in actionBar is black. I tried change color using textColorPrimary to white, but when I did that, all text in my app was change to white.

Here is my 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>

Here is my 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>

Here is my androidmanifest:

<application android:label="@string/ApplicationName" android:theme="@style/MissaoCaronaTheme"></application>

Here is my layout file:

<?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>

Here is my activity:

[Activity(Label = "Usuário")]
    public class UsuarioEditView : MvxActivity<UsuarioViewModel>
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.UsuarioEditView);
        }
    }

4 Answers4

1

please Initialize Your Theme For activity Label part following Code.

[Activity(Label = "Usuário", Theme = "@style/MissaoCaronaTheme", Icon = "@drawable/icon")]

Aboobakkar P S
  • 796
  • 1
  • 8
  • 28
0

Vinícius,

You can create as specific style for the text in the actionBar, and use it for this text only, instead of changing textColorPrimary.

Eg.:

In styles.xml:

<item name="colorTextActionBar">@color/branco</item>

In this case, edit also the color.xml file:

<item name="branco" type="color">#FFFFFFFF</item>
Moahh
  • 29
  • 1
  • 6
0

So when you change the textColorPrimary it is going to affect the overall app theme which means that all the components associated with this style will get affected. That's why all your text changed to white. So, instead of changing the common color you can add a new color of your choice to your choice. You need to make sure that you add the corresponding color in your colors.xml file as well.

In styles.xml :

<item name:"nameOfYourChoice">@color/colorName</item>

And in colors.xml :

<color name="colorName">#colorValue</color>

Make sure you edit your xml files correctly.

Sannjanaa
  • 1
  • 1
0

I found the problem. The problem is the MvxActivity from the MvvmCross framework. I don't know why, but when I'm using MvxActivity with the material design, the text of ActionBar always is black and when I'm using MvxAppCompatActivity with AppCompat theme, the ActioBar title is white.