[英]Best way to animate programatically created bitmaps in android
I have a board game app that creates a lot (hundreds) of bitmaps, and constantly changes them as the game progresses. 我有一个棋盘游戏应用程序,可以创建大量(数百个)位图,并随着游戏的进行不断进行更改。 These bitmaps are created, not loaded from a resource... so they have no R.id to refer to.
这些位图是创建的,不是从资源中加载的...因此它们没有R.id可供参考。
I would like to animate some of them, eg a bitmap moving from one loction to another when a player taps to move it. 我想为其中一些设置动画,例如,当玩家点击以将其移动时,位图从一个位置移动到另一个位置。 What is the best way to do this?
做这个的最好方式是什么?
Note, this is 2.1 and the bitmaps are drawn on a canvas via a matrix translate. 注意,这是2.1,并且位图通过矩阵转换绘制在画布上。
Make this function to get image from drawable folder 使此功能从可绘制文件夹中获取图像
private Bitmap getImageBitmap(){
int resID = getResources().getIdentifier(uri, "drawable",
"a.b.c");
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), resID);
return mBitmap;
}
For set the image , where do you you want> 对于设置图像,您要在哪里>
ImageView imageview01.setImageBitmap(getImageBitmap("name of bitmap");
if you want more about bitmap. 如果您想进一步了解位图。 then you may try this links.
那么您可以尝试此链接。
http://developer.android.com/reference/android/widget/ImageView.html http://developer.android.com/reference/android/widget/ImageView.html
drawable getResources().getIdentifier problem drawable getResources()。getIdentifier问题
setImageURI / setimagebitmap to fetch image from net and display in image view setImageURI / setimagebitmap从网络获取图像并在图像视图中显示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.