绘制在android系统视图多个位图 [英] Draw multiple bitmap on a view in android
问题描述
我试图在其中我有6-7不同照片的图。
有一个在一个视图drwaing只有一个映像没有问题,而是如何在该视图中绘制多个图像。
I am trying to make a view in which i am having 6-7 different images. There is no issue in drwaing only one image on a view, but how to draw multiple images on that view.
下面是我的code -
Here is my code-
Bitmap img1= BitmapFactory.decodeResource(context.getResources(),
R.drawable.football);
这是我的onDraw()方法 -
And here is my onDraw() method-
@Override
protected void onDraw(Canvas canvas) {
setBackgroundColor(Color.GREEN);
float hgt=canvas.getHeight();
float wth=canvas.getWidth();
System.out.println("hgt and wt is "+hgt+" "+wth);
if (startMovement) {
left = 0;
right = 0;
startMovement = false;
}
CheckCorner(canvas);
super.onDraw(canvas);
}
的图像从顶部移动到底部,并且需要显示在一行中。
The images are moving from top to bottom, and need to be displayed in a row.
推荐答案
我只想用一个RelativeLayout的或LinearLayout中。
I would just use a RelativeLayout or a LinearLayout.
RelativeLayout的为您提供关于在何处放置你的意见更多的灵活性,但需要一点点code的布局参数(如果你想放置视图)。 <一href=\"http://stackoverflow.com/questions/2305395/laying-out-views-in-relativelayout-programmatically\">Check这个答案在RelativeLayouts
RelativeLayout gives you more flexibility on where to place your views, but requires a little bit more code for the layout parameters (where you want to place the view). Check this answer on RelativeLayouts
如果你要只是把意见线(水平或垂直),使用的LinearLayout来代替。 <一href=\"http://stackoverflow.com/questions/3204852/android-add-a-textview-to-linear-layout-programmatically\">Check这个答案在LinearLayouts。
If you are going to just put the views in a line (horizontal or vertical), use a LinearLayout instead. Check this answer on LinearLayouts.
这篇关于绘制在android系统视图多个位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!