将稀松布放在使用毕加索显示的ImageView上方

时间:2018-09-28 07:48:06

标签: android xml android-layout imageview picasso

我正在使用Picasso将图像显示到工具栏中的ImageView中,即使它是黑白图片,我也必须使它具有可读性,因此我想添加一个稀松布,该稀松布应从图像底部开始添加阴影,就像这样。

Left without scrim, right with scrim

我已经尝试将其添加到xml中,并且被毕加索(Picasso)显示的图像所覆盖,还尝试使用java添加它,但是没有用....如果可以,请帮帮我!

在这里发布我使用的代码。

ImageView header;
    header = findViewById(R.id.tour_image);

    if(String.valueOf(getIntent().getStringExtra("image")).equals(getApplicationContext().getResources().getString(R.string.no_image))) {
        Picasso.get()
                .load(String.valueOf(getIntent().getStringExtra("image")))
                .fit()
                .centerInside()
                .into(header);
    }else{
        Picasso.get()
                .load(String.valueOf(getIntent().getStringExtra("image")))
                .fit()
                .into(header);
    }

    header.setBackground(getResources().getDrawable(R.drawable.scrim));

<ImageView
            android:id="@+id/tour_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/scrim"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax"/>

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

CollapsingToolbarLayout

中添加具有稀松布的视图
     <android.support.design.widget.CollapsingToolbarLayout>

         <ImageView />

         <View 
             background="@drawable/scrim"
             android:layout_width="match_parent"
             android:layout_height="match_parent" />

         <android.support.v7.widget.Toolbar />

     </android.support.design.widget.CollapsingToolbarLayout>