0

hello im new in android programming, i wanna ask how to translate bitmap up and down with float input ? here is my code :

bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.horizonsx);
bmpWidth = bitmap.getWidth();
bmpHeight = bitmap.getHeight();
drawMatrix();

private void drawMatrix(){

Matrix matrix = new Matrix();
matrix.setTranslate(0,10);


  Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0,0, bmpWidth, bmpHeight, matrix, true);

 imageviewrot.setImageBitmap(resizedBitmap);
imageviewrot.setScaleType(ScaleType.CENTER); ///THIS WAS THE KEY LINE

}

but failed to translate the bitmap up with value of 10. How i can do it ? thank you

1 Answers1

0

make use of sprites...where a sprite will hold ur bitmap and then we can make translation/rotation on sprite

take some tips from here

Community
  • 1
  • 1
x-code
  • 608
  • 1
  • 10
  • 30
  • if i manipulate the xml code with translation , it works , but how manipulate xml code in java ? – user2307181 Jul 29 '13 at 07:55
  • im sory ,still dont understand the answer of that reference, is there any other reference? – user2307181 Jul 29 '13 at 08:04
  • wht are the things apart from a bitmap u want to show on a page...is dat only bitmap that is there to view or anything else...try to be clear with ur need (not mentioning the code what u have written) so dat i can help....coz in cases ur req will be something and to fulfill u might be using a wrong direction... so let me know wt u want to show on the screen.... – x-code Jul 29 '13 at 09:22
  • i have horizon bitmap , i want to make flight indicator app, so i want to translate up and down that horizon bitmap as i change the y axis on that bitmap from streaming input data, thats what i do, please help me – user2307181 Jul 29 '13 at 09:47
  • the horizon bitmap is an atlas rit (or else what is it)?... and u want to have a plane to show on the atlas... so u will have two bitmaps...one atlas and one plane rit? – x-code Jul 29 '13 at 09:57
  • thats right, i already put the plane with rotation , now i need a horizon that can move up and down.. i set the matrix.settranslate not works – user2307181 Jul 29 '13 at 10:13
  • then look no further, google 'sprite tutorials in android' bye – x-code Jul 29 '13 at 10:17