0

Here is my main_activity.xml and below you can see the style I am using

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/nav_host_container"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottom_nav"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:itemIconTint="@color/color_white"
            app:itemTextColor="@color/color_white"
            app:menu="@menu/bottom_nav" />
    </LinearLayout>
</layout>




  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:colorPrimary">#3f51b5</item>
        <item name="android:textColorPrimary">#FF0000</item>
        <item name="colorPrimary">#3f51b5</item>
  </style>

and Programmatically I don't know how to change actionbar title color and actually I could not change text color in xml as well (but the later one I just want to know for curiosity ) I need to change actionbar title color Programmatically

Artur A
  • 257
  • 3
  • 20

1 Answers1

0

Try to use this code, hope it will help you !!

  getActionBar().setTitle(Html.fromHtml("<font color='#ff0000'>ActionBartitle </font>"));
Amninder Singh
  • 321
  • 1
  • 10
  • I want to change text color not background color of actionbar – Artur A Aug 09 '19 at 11:17
  • I put it in onCreate it crashes saying nullpointerexception and my theme is Theme.AppCompat.Light.DarkActionBar – Artur A Aug 09 '19 at 11:43
  • I have changed to supportActionBar but it doesn't change neighter color and nor text – Artur A Aug 09 '19 at 11:53
  • Ok, try to use this one https://stackoverflow.com/questions/9920277/how-to-change-action-bar-title-color-in-code – Amninder Singh Aug 09 '19 at 11:56
  • Actually it works the problem is I have bottomnavigation and in navigation graph I have label ,which is overriding, but when I move your code to each fragment it works so thanks – Artur A Aug 09 '19 at 12:06