在使用 Picasso 显示的 ImageView 上方放置稀松布
Place a scrim above an ImageView shown using Picasso
我正在将使用 Picasso 的图像显示到工具栏的 ImageView 中,我必须使工具栏标题可读,即使它是黑白图片,所以我想添加一个应该从底部开始添加阴影的稀松布图像,就像这样。
我试过将它添加到 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"/>
感谢您的帮助!
在 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>
我正在将使用 Picasso 的图像显示到工具栏的 ImageView 中,我必须使工具栏标题可读,即使它是黑白图片,所以我想添加一个应该从底部开始添加阴影的稀松布图像,就像这样。
我试过将它添加到 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"/>
感谢您的帮助!
在 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>