我有一个图像,我想在底部添加黑色透明以显示文本细节。从服务器,我会得到正常的图像,我想像下面这样转换它。在下面的图片中,您可以看到图像的底部有黑色透明。如何在android中的图像上放置黑色透明
3
A
回答
16
试试这个
<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>
3
将使用的FrameLayout图像上方的另一个ImageView的并将其设置为源:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#8000"
android:endColor="#0000"/>
</shape>
1
这可以通过创建gradients.check this
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:startColor="#4C4C43"
android:endColor="#B8B894"
android:angle="270" />
</shape>
</item>
</selector
>
可以使用
0
您可以使用alpha属性
android:alpha="0.0" thats invisible
android:alpha="0.5" see-through
android:alpha="1.0" full visible
相关问题
- 1. Objective-C - 如何在图像中放置黑色透明
- 2. 在Android中放置半透明图像
- 3. 如何在CSS中的图像上放置不透明的白色渐变?
- 4. 使黑色像素透明
- 5. 透明图像在缓存位图上显示为黑色
- 6. 图像上的黑色透明覆盖图
- 7. 为什么透明像素在图像中显示为黑色?
- 8. Android的透明图像获得纯黑色化背景
- 9. 如何在img上放置文本,并使图像透明
- 10. 如何在图像上放置透明按钮?
- 11. 如何让背景图像的黑色部分透明?
- 12. 在ImageView中的不透明图像上的透明图像
- 13. 85%不透明度的Android黑色
- 14. 如何将带有透明背景的白色徽标图像放在黑色标题中?
- 15. 像素每像素图像,透明变成黑色
- 16. 构建轮流部分透明的图像像素黑色
- 17. 黑色背景上的NSColor透明度?
- 18. 如何在窗体上放置透明颜色?
- 19. 如何在布局中的图像上放置半透明按钮?
- 20. android图像透明
- 21. UIBarButtonItem - 如何制作半透明黑色?
- 22. ImageMagick:在图像上放置部分透明的瓷砖
- 23. 为什么图像上有不透明度如何在图像上放置不透明度并在div上放置悬停功能?
- 24. 在IE7-8中褪色透明图像
- 25. Imagemagick在旋转透明图像上的不需要的黑色背景
- 26. iOS着色透明图像
- 27. Android:使背景图像中的特定(绿色)颜色透明
- 28. 位图转换 - 从B&W源创建透明+黑色图像
- 29. iOS 5黑色透明UIAlertView
- 30. 透明圆圈黑色
节约了大量hours..thanks的@shijil – CrazyMind 2016-09-26 10:30:33
这救了我的命。谢谢 :) – Grcn 2017-09-19 03:59:04