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
CodePudding user response:
you can simply use a FrameLayout with 2 nested views inside, first add your ImageView and then add a view with gradient shape.
<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>
CodePudding user response:
You can set a color filter like this:
background.setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN);