简体   繁体   中英

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.

<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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM