Transparent actionBar and statusBar in Android lollipop

前端 未结 3 655
礼貌的吻别
礼貌的吻别 2020-12-19 07:37

I am trying to create this interface :

\"enter

And here is my actual result :<

相关标签:
3条回答
  • 2020-12-19 08:06

    You can change your toolbar color to transparent like this:

    mToolbar.setBackgroundColor(getResources().getColor(android.R.color.transparent));
    

    You can change it's background on the XML too:

    android:background="@android:color/transparent"
    

    Or if you're using ActionBar:

    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent)));
    

    Use getActionBar() if you're not using ActionBarActivity

    Result:

    enter image description here

    0 讨论(0)
  • 2020-12-19 08:17

    For API that >= 21, add to theme these lines of code

    <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarColor">@android:color/transparent</item>

    Don't forget to add

    android:fitsSystemWindows="true"

    0 讨论(0)
  • 2020-12-19 08:18

    Use this style:

    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <item name="android:textColorPrimary">@color/my_text_color</item>
        <item name="colorPrimary">@android:color/transparent</item>
        <item name="windowActionBarOverlay">true</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题