Android - new BitmapDrawable deprecated 创建一个空白的drawable
来源:互联网 发布:mac版qq群文件在哪 编辑:程序博客网 时间:2024/06/05 11:22
创建一个空白的drawable
myPopupWindow.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
I've used a PopupWindow. With this PopupWindow I set the BackgroundDrawable to an empty BitmapDrawable.
When I use the following code it gives a deprecated warning:
myPopupWindow.setBackgroundDrawable(new BitmapDrawable());
So I changed it to:
myPopupWindow.setBackgroundDrawable(new BitmapDrawable( getApplicationContext().getResources(), Bitmap.createBitmap(0, 0, Bitmap.Config.ARGB_8888)));
This gave me an error that a Bitmap must have a width and height bigger than 0.
Right now I use:
myPopupWindow.setBackgroundDrawable(new BitmapDrawable( getApplicationContext().getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)));
And it works. But it just seems a bit wrong to use a 1x1 pixel Bitmap instead of a completely empty one like I want to. Is there another way to actually use an empty BitmapDrawable, instead of one that is 1 by 1 pixels?
Ok, instead of
myPopupWindow.setBackgroundDrawable(new BitmapDrawable());
OR
myPopupWindow.setBackgroundDrawable(new BitmapDrawable( getApplicationContext().getResources(), Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)));
I just use a background-color that I want to set to the PopupWindow. So for example, one of my PopupWindows just had a few Images without margins in between them, so I just used a Transparent background for it:
myPopupWindow.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
And for another one I wanted to use a white background anyway, so I've used:
myPopupWindow.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.WHITE));
- Android - new BitmapDrawable deprecated 创建一个空白的drawable
- Android的Drawable之BitmapDrawable
- Android-drawable资源-BitmapDrawable
- Android中BitmapDrawable的一个bug
- 通过new BitmapDrawable()方法将Bitmap转化为Drawable的getIntrinsicHeight()和getIntrinsicWidth() 问题。
- 从Drawable到BitmapDrawable的转换
- 从Drawable到BitmapDrawable的转换
- android BitmapDrawable的使用
- android BitmapDrawable的使用
- android BitmapDrawable的使用
- android BitmapDrawable的使用
- android BitmapDrawable的使用
- Android BitmapDrawable()的使用
- Android BitmapDrawable()的使用
- Bitmap , BitmapDrawable ,Drawable,byte[]
- Bitmap , BitmapDrawable ,Drawable,byte[]
- Drawable学习之---BitmapDrawable
- Android Drawable Resource学习(二)、BitmapDrawable和Bitmap
- Infographics
- 即兴题——分别求一组数的正、负数之和
- fedora安装之后
- 软件需求
- Java线程(一):线程安全与不安全
- Android - new BitmapDrawable deprecated 创建一个空白的drawable
- Linux下进程之间信号量互斥、同步
- 赠送 HttpClient 和HttpURLConnection 的轻型网络框架 ---》按照自己的需求定制修改框架
- unity 接移动mm sdk
- CPaintDC、CClientDC、CWindowDC和CMetaFileDC类的主要特点及区别
- 读入外挂
- 有一种毒药叫成功---成功学的泛滥与迷失
- Android手机截图代码(针对root设备,可截取任意屏幕)
- warning: no rule to process file '$(PROJECT_DIR)/MyWebView/HighlightedString