我无法弄清楚如何在图像上应用滤镜。
在这种情况下,我希望图像更暗(黑色,40%透明度,图像顶部的图层将给我我想要的结果)。但是,如果我知道如何在任何颜色的图像(具有一定的透明度)上放置图层以使其在视觉上与应用程序的其他UI元素更加兼容,那将是有用的(将来)。
它现在看起来如何。
我希望它如何在应用程序上查看(上面的图像已在Adobe Illustrator中编辑但是如果我使用它,即使它的大小不大,应用程序也会反复崩溃)
此外,我怀疑在Android工作室必须有一种方法可以做到这一点,而无需任何图像编辑软件。
如果我错了,请纠正我;)
这就是我做的,
imageView =(ImageView) findViewById(R.id.image_view) ;
imageView.getDrawable().setColorFilter(0x76ffffff, PorterDuff.Mode.MULTIPLY );
颜色范围[0x00000000 -0xffffffff]
如果您不理解这种模式,这可能对您有所帮助
红色 - 0xffff0000
绿色-0xff00ff00
蓝色 - 0xff0000ff
您的要求平均黑色0xff555555
根据需要更改颜色代码> here
出去
更多:
setColorFilter params:(int color,PorterDuff.Mode mode)
您可以使用对象的android:foreground
属性在任何对象上设置颜色。在这里我使用ImageView
来显示图像和android:foreground
来放置一个过滤器!
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/yourImage"
android:foreground="#60000000" />
</RelativeLayout>
如果你想做这个布局然后使用android:background属性而不是android:src
作为图像源。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/yourImage"
android:foreground="#60000000">
</RelativeLayout>
使用任何在线工具为较暗的图像生成9个补丁图像,并在您的应用程序中使用该9补丁。它会工作。
试试这个:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha=".5"
android:src="@drawable/your_naruto_img"/>
</RelativeLayout>
当然,您可以通过更改android:alpha
[0 - 1]来相应地调整不透明度。
希望这可以帮助!
试试这个:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/your_drawable">
<ImageView
android:id="@+id/backImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66000000"
android:scaleType="fitXY"/>
</RelativeLayout>
您可以将图像设置为RelativeLayout
的背景。使用imageview
标记并使用要设置的transparent
颜色设置背景。
对我有用的是
ImageView backgroundimage = FindViewById<ImageView>(Resource.Id.img_view);
backgroundimage.SetColorFilter(Color.Argb(200,0,0,0), PorterDuff.Mode.Overlay);
在尝试了以上所有答案之后。希望它可以帮助某人。