ImageView img=new ImageView(this);
//You can use like that without using Bitmap
img.setImageResource(R.drawable.arrow_s);
In android the best format of Image is PNG as it light compare to JPG,JPEG etc.So its easy to draw and take less time to perform the operation while using these images.
As to the original question, PNG comes is many forms (see: 'PNG color options' and 'PNG color types' on the PNG Wiki page) -- Is there a favoured PNG format for Android?
发布评论
评论(2)
在android中,最好的图像格式是PNG,因为它比JPG、JPEG等轻,所以它很容易绘制,并且在使用这些图像时花费更少的时间来执行操作。
对于位图,请执行此操作
位图帮助
已编辑
是的,如果资源中有图像,则无需使用 Bitmap。如果您的图像在 Drawable 中,则
使用
In android the best format of Image is PNG as it light compare to JPG,JPEG etc.So its easy to draw and take less time to perform the operation while using these images.
And For bitmap Go through this
Bitmap Help
Edited
Yes no need to use Bitmap ,if you have images in resource.If your images are in Drawable then
use
请注意:“img.setImageResource(...)”仍然调用位图例程,可能在 UI 线程上:
http://developer.android.com/reference/android /widget/ImageView.html#setImageResource%28int%29
这可能会导致不良的 UI 滞后,因此您可能需要在单独的线程中自己处理 BitmapFactory,如所讨论的 这里:
http://developer.android.com/training/displaying-bitmaps/index.html
至于最初的问题,PNG 有多种形式(请参阅:PNG Wiki 页面上的“PNG 颜色选项”和“PNG 颜色类型”)——Android 是否有一种受青睐的 PNG 格式?
Note that: "img.setImageResource(...)" still calls the bitmap routines, potentially on UI thread:
http://developer.android.com/reference/android/widget/ImageView.html#setImageResource%28int%29
That may cause undesirable UI-lags, so you might want to deal with the BitmapFactory yourself, in a seperate thread, as discussed here:
http://developer.android.com/training/displaying-bitmaps/index.html
As to the original question, PNG comes is many forms (see: 'PNG color options' and 'PNG color types' on the PNG Wiki page) -- Is there a favoured PNG format for Android?