【发布时间】:2016-04-05 06:17:59
【问题描述】:
【问题讨论】:
标签: android android-layout gradient
【问题讨论】:
标签: android android-layout gradient
只要确保您使用 RelativeLayout 来放置 Toolbar 和 body。 将工具栏放在最后。 为工具栏的 android:background 属性设置透明颜色 这是一个工作代码的例子:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="vertical">
<fragment
android:id="@+id/fragment_editor"
android:name="ichsan.myapp.HelloFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="@layout/fragment_editor" />
<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#10000000"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</RelativeLayout>
【讨论】:
玻璃风格的背景比简单的透明度要复杂一些。您可能想使用intrinsic blur。因此,这样做的方法是采用简单的白色图像,执行内在模糊 -> 将模糊的输出位图设置为 toolbar 的背景。现在将 alpha 设置为 0.6f 附近的某个位置,您将得到类似的东西。它不会与您提供的图像完全一样,但可能是获得类似效果的最简单方法。
【讨论】: