[英]How can I darker in ImageView
I need to change the image programmatically setting an type of "darker".我需要以编程方式更改图像,设置一种“较暗”的类型。 I need do that bacause the text view in the recycler view need to be in contrast with the background image.
我需要这样做,因为回收站视图中的文本视图需要与背景图像形成对比。 How can I put this effect?
我怎样才能把这个效果? I need something like this
我需要这样的东西
you can simply use a FrameLayout with 2 nested views inside, first add your ImageView and then add a view with gradient shape.您可以简单地使用一个带有 2 个嵌套视图的 FrameLayout,首先添加您的 ImageView,然后添加一个具有渐变形状的视图。
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/dragon_ball_super" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shome_gradient_shape"/>
</FrameLayout>
You can set a color filter like this:您可以像这样设置滤色器:
background.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.