简体   繁体   English

我怎样才能在 ImageView 中变暗

[英]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.

相关问题 如何将自定义 ImageView 与 DataBinding 结合使用? - How can I use my custom ImageView with DataBinding? 如何使用 xml 文件中定义的高度宽度和源定义 ImageView? - How can I define ImageView with height width and source defined on xml file? 无法解码 stream:java.io.FileNotFoundException。 如何在 Imageview 上显示图像? - Unable to decode stream: java.io.FileNotFoundException. how can I display image on Imageview? 如何将 imageview 保存到图库中? - How do I save an imageview into the gallery? 如何旋转ImageView和Carousel - How do I rotate an ImageView along with a Carousel 为什么我不能用 Kotlin 更改 ImageView 的可见性? - Why I can't change the visibility of my ImageView with Kotlin? 如何像本应用程序一样保持imageview的长宽比? [Android,ImageView,长宽比,ScrollView] - How do I maintain aspect ratio of an imageview like in this application? [Android, ImageView, Aspect ratio, ScrollView] 如何在 tornadofx imageview 中显示新图像? - How do I display a new image in tornadofx imageview? 如何使用Kotlin从imageView获取像素颜色? - How do I get a pixel color from an imageView using Kotlin? Kotlin:如何将ImageView的内容保存到内部/外部存储器? - Kotlin: How do I save the contents of an ImageView to the internal/external memory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM