1

I have several days now that I am trying to make this work properly.I am trying to set a custom layout for my application's toolbar

<android.support.v7.widget.Toolbar
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="#fff"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:id="@+id/toolbar">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-smallcaps"
        android:text="@string/app_name"
        android:textColor="@color/green"
        android:textSize="16sp"
        android:textStyle="bold"
         />
</android.support.v7.widget.Toolbar>`

Manifest.XMl

android:theme="@style/MyMaterialTheme">

and my styles.xml:

<style name="MyMaterialTheme" parent="MyMaterialTheme.Base">
</style>

<style name="MyMaterialTheme.Base"  parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

In my mainLayout it seems when I am editing it works ok,when I run the application doesn't can sb help me?

1 Answers1

2

Try this

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#fff"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="sans-serif-smallcaps"
                android:text="@string/app_name"
                android:textColor="@color/green"
                android:textSize="16sp"
                android:textStyle="bold" />
        </LinearLayout>
    </android.support.v7.widget.Toolbar>
AskNilesh
  • 67,701
  • 16
  • 123
  • 163