B
B
boomwest2015-07-07 16:29:43
Android
boomwest, 2015-07-07 16:29:43

How to style a toolbar that is used instead of an ActionBar?

The application inherits from Theme.AppCompat.Light.NoActionBar.
Layout has a toolbar:

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:popupTheme="@android:style/ThemeOverlay.Material.Light" />

If this layout is used in an Activity, then the style is applied, and on the black actionbar there is a white UP button.
If layout is used in a fragment, then the style is not applied and the black UP button on the black actionbar.
9b4462da227d4b9eaa25dfb0fa2799e5.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bolshakov, 2015-08-25
@enq3

You can set any markup, Toolbar is a container:

<android.support.v7.widget.Toolbar
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:popupTheme="@android:style/ThemeOverlay.Material.Light"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp" >
   <LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:background="#ffffff">
  </LinearLayout>
</android.support.v7.widget.Toolbar>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question