【问题标题】:Design transparent glass type bar with gradient设计带渐变的透明玻璃条
【发布时间】:2016-04-05 06:17:59
【问题描述】:

我正在尝试设计一个像这样的透明玻璃型酒吧-

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

提前致谢

【问题讨论】:

    标签: android android-layout gradient


    【解决方案1】:

    只要确保您使用 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>
    

    来源:transparent Actionbar with AppCompat-v7 21

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2019-04-27
        • 2011-07-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多