java - 如何在android中的图像上放置黑色透明

标签 java android xml android-layout android-fragments

我有一张图片,我想在底部添加黑色透明以显示文本详细信息。从服务器我会得到正常的图像,我想像下面这样转换它。在下图中,您可以看到图像底部有黑色透明。

enter image description here

最佳答案

试试这个

<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/

相关文章:

java - java中使用==检查null时出现空指针异常

android - "ArrayAdapter requires the resource ID to be a TextView"XML问题

python - 如何解决 xml.etree.ElementTree.iterparse() 中的 Unicode 错误?

xml - vbscript 获取 XML 节点值并分配给变量

java - 按钮按下事件

java - Android FLAG_ACTIVITY_NEW_TASK 不起作用

android - 在测试项目中使用资源文件夹获取测试字符串数据

行中带有可点击项目的 Android ListView 会导致继续滚动时出现问题

java - 如何在 Eclipse 中备份我的 java 项目?

android - 如何使用 gradle 生成签名和未签名的 APK?