java - Rendering an ImageView with absolute size and coordindate -
i hate learn complicated stuff imageview. want this:
image_view.setx(200); image_view.sety(200); image_view.setwidth(50); image_view.setheight(50);
it must not affected gravity. want absolute position , absolute size (by pixel).
can me simplify android programming since had previous experience 2d computer development before? thank you.
i have scale each image beforehand, not use imageview functions scale images.
final int square_size = 150; bitmap bm = bitmapfactory.decoderesource(getresources(), r.drawable.android_img); bitmap bm2 = bitmapfactory.decoderesource(getresources(), r.drawable.android_img2); imageview image_view1 = new imageview(this); image_view1.setimagebitmap(bitmap.createscaledbitmap(bm, square_size, square_size, false)); image_view1.setlayoutparams(new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); image_view1.setx(0); image_view1.sety(0); image_view1.setscaletype(imageview.scaletype.matrix); imageview image_view2 = new imageview(this); image_view2.setimagebitmap(bitmap.createscaledbitmap(bm2, square_size, square_size, false)); image_view2.setlayoutparams(new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); image_view2.setx(square_size + 20); image_view2.sety(0); image_view2.setscaletype(imageview.scaletype.matrix); imageview image_view3 = new imageview(this); image_view3.setimagebitmap(bitmap.createscaledbitmap(bm2, square_size, square_size, false)); image_view3.setlayoutparams(new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); image_view3.setx(0); image_view3.sety(square_size + 20); image_view3.setscaletype(imageview.scaletype.matrix); imageview image_view4 = new imageview(this); image_view4.setimagebitmap(bitmap.createscaledbitmap(bm, square_size, square_size, false)); image_view4.setlayoutparams(new layoutparams(layoutparams.match_parent, layoutparams.match_parent)); image_view4.setx(square_size + 20); image_view4.sety(square_size + 20); image_view4.setscaletype(imageview.scaletype.matrix); relativelayout views = new relativelayout(this); views.addview(image_view1); views.addview(image_view2); views.addview(image_view3); views.addview(image_view4); setcontentview(views);
and result looks plausible! how wonderful can be!
Comments
Post a Comment