【问题标题】:How to blur the Collapsing toolbar image whan expanded like WhatsApp?如何模糊像 WhatsApp 一样展开的折叠工具栏图像?
【发布时间】:2018-05-26 13:17:40
【问题描述】:

我认为这个问题已经回答了很多次,但没有一个对我有用。我有一个折叠工具栏,其中包含使用毕加索从网络加载的图像。展开折叠工具栏时,我在图像上显示标题。但我的问题是,当图像颜色较浅时,我看不到标题,因为它是白色的。

我尝试在 XML 中将色调设置为 Imageview,

android:tint="@color/colorGrey"

但它适用于整个图像。

我检查了 What's app 上的折叠工具栏,它在标题所在的底部有一个模糊的图像。那么,如何实现What's app collapsing toolbar image之类的模糊效果呢?

【问题讨论】:

    标签: android android-layout imageview android-toolbar android-collapsingtoolbarlayout


    【解决方案1】:

    我通过参考这个answer 弄清楚了。我刚刚在CollapsingToolbarLayout 中添加了两个视图。一个将layout_gravity 放在顶部,另一个放在底部。如下所示,

    <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbar">
    
            <ImageView
                android:id="@+id/iv_cover_photo"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax" />
    
            <View
                android:layout_width="match_parent"
                android:layout_height="120dp"
                android:layout_gravity="center_horizontal|bottom"
                android:background="@drawable/image_gradient_bottom" />
    
            <View
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_gravity="top"
                android:background="@drawable/image_gradient_top" />
    
    
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />
    

    现在,这看起来几乎类似于 Whats 的 App android 个人资料页面图像。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 2016-06-28
      • 2016-10-03
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多