[英]How to make image asset with transparent background in Android studio? (with option add image asset)
I have image with transparent background.我有透明背景的图像。
When i add image to resource folder, my background changes to white.当我将图像添加到资源文件夹时,我的背景变为白色。 (with android studio add image asset option)
(使用 android studio 添加图像资产选项)
If i put image directly to resource file, image background stays transparent.如果我将图像直接放入资源文件,图像背景将保持透明。
Try this: 尝试这个:
ImageView myImage = (ImageView) findViewById(R.id.myImage);
myImage.setAlpha(127); //value: [0-255]. Where 0 is fully transparent and 255 is fully opaque
选择“操作栏和选项卡图标”而不是“启动器图标” ,您将获得所有图像所需的透明背景。
Here is what is to be done in order to set the app icons generated to have transparent background这是为了将生成的应用程序图标设置为具有透明背景而要做的事情
Edit the ic_launcher_background.xml file generated and set it like below:编辑生成的 ic_launcher_background.xml 文件并将其设置如下:
This will remove the default background generated to be transparent color only.这将删除生成为仅透明颜色的默认背景。
Remove all the path definitions and only have the following one删除所有路径定义,只有以下一个
<path android:fillColor="#00000000"
android:pathData="M0,0h108v108h-108z"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.