Android transparent overlay toolbar

前端 未结 8 2044
[愿得一人]
[愿得一人] 2020-12-08 07:57

I created a ToolBar which I set as my ActionBar and I have it transparent, my question is I want it to overlay the rest of the content, right now i

相关标签:
8条回答
  • 2020-12-08 08:56

    in styles.xml:

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        ...
    </style>
    
    <style name="ActionBar.SemiTransp" parent="Base.Widget.AppCompat.ActionBar">
        <item name="displayOptions">showHome|showTitle</item>
        <item name="background">@drawable/gray_to_transp</item>
    </style>
    
    <style name="AppTheme.SemiTranspActionBar" parent="@style/AppTheme">
        <item name="actionBarStyle">@style/ActionBar.SemiTransp</item>
        <item name="windowActionBarOverlay">true</item>
    </style>
    

    and in the manifest:

    <activity
            android:name=".MainActivity"
            android:theme="@style/AppTheme.SemiTranspActionBar">
    
    0 讨论(0)
  • 2020-12-08 08:56

    You can use CoordinatorLayout as below

    <android.support.design.widget.CoordinatorLayout
    android:id="@+id/coordinatorLayout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.epbit.itattooz.MainActivity">
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical">
    
        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:minHeight="?android:attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark"
            android:titleTextAppearance="@style/ToolbarTitle"/>
    
        <FrameLayout
            android:id="@+id/containerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </LinearLayout>
    
    </android.support.design.widget.CoordinatorLayout>
    

    Where frameLayout is for used fragments.

    0 讨论(0)
提交回复
热议问题