简体   繁体   中英

Android actionbar title - change background color

In my Android toolbar on the top I'm using gradient colors on the background. It works just fine, but I noticed the title is wrapped inside something that inherits another one of the gradient colors. How can I change the background of the title into transparent?

<style name="Toolbar" parent="@style/ThemeOverlay.AppCompat.ActionBar">
    <item name="android:background">@drawable/toolbar_gradient</item>
</style>


<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:elevation="4dp"
    app:titleTextColor="@color/white"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:theme="@style/Toolbar"/>

[..[ x ] ... y ]

So the container x wraps the title and has a background color that stands out from the toolbar y.

Add your custom toolbar with title.

<android.support.v7.widget.Toolbar
    android:id="@+id/my_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:elevation="4dp"
    app:titleTextColor="@color/white"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:theme="@style/Toolbar">
<TextView android:id="@+id/footer" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:textSize="25sp"
        android:singleLine="true" android:background="#07000000"
        android:textColor="#FFFFFF" android:text="rrrrr"
        android:layout_centerInParent="true"
        android:layout_alignParentBottom="true" />// set your background as you wish
</android.support.v7.widget.Toolbar>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM