[英]How to add rainbow gradient to an Image in android
I want to add Transparent Rainbow or Spectrum Gradient to Bitmap
. 我想向
Bitmap
添加“ 透明彩虹”或“光谱渐变” 。
In photoshop
it is very easy. 在
photoshop
这非常容易。 Now I want to do it programmatically
. 现在,我要以
programmatically
。 I have gone through a lot of research. 我已经做了很多研究。 But gradient has only one
starting color
and one ending
. 但是渐变只有一种
starting color
和一种ending
starting color
。 How could I add the rainbow color(multiple color) Gradient in Android. 如何在Android中添加彩虹色(多种颜色)渐变。
Or is there a way to add that effect to bitmap in Android? 还是有办法在Android中将这种效果添加到位图? Like given
像给定的
for this you can use a translucent image with the desired gradient and put it on top of your image view in a FrameLayout
. 为此,您可以使用具有所需渐变的半透明图像并将其放在
FrameLayout
中的图像视图顶部。 then capture bitmap of the view. 然后捕获视图的位图。
once you get your layout ready use this answer to capture bitmap from it 一旦您准备好布局,请使用此答案从中捕获位图
try this to convert a view (framelayout) into a bitmap:
尝试这样将视图(框架布局)转换为位图:
public Bitmap viewToBitmap(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); return bitmap; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.