0

https://developer.android.com/training/material/theme.html#StatusBar开始,我有很多关于如何让状态栏透明但不太多运气的试验和错误。Android 5.0半透明状态栏

我不想抽屉式导航只是一个平面,简单的活动与半透明的状态栏像他们展示在http://www.google.com/design/spec/style/imagery.html#imagery-best-practices

这里是我的设计

 <style name="AppTheme" parent="android:Theme.Material.NoActionBar"> 
     <!-- All customizations that are NOT specific to a particular API-level can go here. --> 
     <item name="android:windowActionBar">false</item> 
       <!-- your app branding color for the app bar --> 
     <item name="android:colorPrimary">@android:color/transparent</item> 
     <!-- darker variant for the status bar and contextual app bars --> 
     <item name="android:colorPrimaryDark">@android:color/transparent</item> 
     <item name="android:statusBarColor">@android:color/transparent</item> 
       <item name="android:fitsSystemWindows">true</item> 

     <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
     <item name="android:windowTranslucentStatus">true</item> 
     <item name="android:windowTranslucentNavigation">true</item> 
        <item name="android:windowNoTitle">true</item> 
     <item name="android:windowBackground">@android:color/transparent</item> 
<item name="android:windowContentOverlay">@null</item> 


    </style> 

和代码在Java

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, 
      WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
    getWindow().getAttributes().flags &= (~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); 
    getWindow().setStatusBarColor(Color.TRANSPARENT); 

    getWindow().getDecorView().setSystemUiVisibility(
      View.SYSTEM_UI_FLAG_LAYOUT_STABLE 
      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION 
      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN 
      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION 
      | View.SYSTEM_UI_FLAG_FULLSCREEN 
      | View.SYSTEM_UI_FLAG_IMMERSIVE); 

我已经经历了很多stackoverflow的答案,包括使用ScrimInsetsFrameLayout,但似乎没有达到像fol一样简单的东西降低确切的规则

您也可以自己在状态栏后面绘制。例如,如果要在照片上透明地显示状态栏,并使用细微的黑色渐变来确保白色状态图标可见。为此,请将android:statusBarColor属性设置为@android:color/transparent并根据需要调整窗口标志。您还可以使用Window.setStatusBarColor()方法进行动画或淡入淡出。注意:状态栏应该总是从主要工具栏清楚地描述,除非您在这些栏后显示边缘到边缘的丰富图像或媒体内容,并且您使用渐变来确保图标仍然可见。

回答

1

这可以使用xml来完成。使用framelayout,以便您可以在其中添加两个或更多个图像浏览。