答案 0 :(得分:0)
确保使用RelativeLayout来铺设工具栏和正文。 将工具栏放在最后。 为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>
答案 1 :(得分:0)
玻璃风格的背景比简单的透明度要复杂一些。您可能想要使用intrinsic blur。所以这样做的方法是采用简单的白色图像,执行内在模糊 - &gt;将模糊输出位图设置为toolbar
的背景。现在将alpha设置为0.6f
附近的某个地方,你就会有类似的东西。它不会完全像您提供的图像,但可能是获得类似效果的最简单方法。