设计透明玻璃型条形渐变色

时间:2016-04-05 06:17:59

标签: android android-layout gradient

我正在设计一个像这样的透明玻璃型条 -

enter image description here

我的设计很差。我怎样才能实现它。有没有财产?

先谢谢

2 个答案:

答案 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>

来源:transparent Actionbar with AppCompat-v7 21

答案 1 :(得分:0)

玻璃风格的背景比简单的透明度要复杂一些。您可能想要使用intrinsic blur。所以这样做的方法是采用简单的白色图像,执行内在模糊 - &gt;将模糊输出位图设置为toolbar的背景。现在将alpha设置为0.6f附近的某个地方,你就会有类似的东西。它不会完全像您提供的图像,但可能是获得类似效果的最简单方法。

相关问题