Jit*_*r M 10 android gradient android-statusbar android-6.0-marshmallow
我正在尝试将类似的状态栏和导航栏渐变设置为Google Now.
图像参考:矩形区域如下所示
在Android Marshmallow上尝试以下选项后,
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
Run Code Online (Sandbox Code Playgroud)
我得到以下行为
图片参考:
谁能建议我如何在这两个上获得渐变?
那是一个渐变还是阴影?
它是一种用作稀松布的渐变色.要实现此效果,您首先要做的是删除状态和导航栏的半透明参考底图.另一个答案详述了如何在较低平台设备上执行此操作; 但是在Android Lollipop及更高版本上,只需将两个样式属性设置为透明即可实现此目的:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme" parent="android:Theme.Material.Wallpaper.NoTitleBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
然后,要添加稀松布,您可以使用可绘制的形状:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:type="linear"
android:angle="270"
android:centerY="0.3"
android:startColor="#66000000"
android:centerColor="#33000000"
android:endColor="#00000000"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
然后你可以将它设置为View布局中的背景:
<View
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@drawable/scrim"/>
Run Code Online (Sandbox Code Playgroud)
您还可以将android:rotation="180"属性设置为对屏幕底部使用相同的渐变.
| 归档时间: |
|
| 查看次数: |
3124 次 |
| 最近记录: |