我有一张图片,我想在底部添加黑色透明以显示文本详细信息。从服务器我会得到正常的图像,我想像下面这样转换它。在下图中,您可以看到图像底部有黑色透明。
最佳答案
试试这个
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ur_image" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_bg" >
</FrameLayout>
和gradient_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#59000000"
android:endColor="@android:color/transparent"
android:startColor="#000000" />
</shape>
关于java - 如何在android中的图像上放置黑色透明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27061901/