Android: Pivoter l'image dans imageview par un angle

J'utilise le code suivant pour faire pivoter une image dans ImageView par un angle. Est-il plus simple et moins complexe que la méthode disponible.

ImageView iv = (ImageView)findViewById(imageviewid);
TextView tv = (TextView)findViewById(txtViewsid);
Matrix mat = new Matrix();
Bitmap bMap = BitmapFactory.decodeResource(getResources(),imageid);
mat.postRotate(Integer.parseInt(degree));===>angle to be rotated
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,bMap.getWidth(),bMap.getHeight(), mat, true);
iv.setImageBitmap(bMapRotate);
  • PS pour 2014, il semble que vous pouvez tout simplement mis de "rotation" dans le XML dans Android Studio. (Vous pouvez même il suffit de cliquer sur "expert" propriétés du bouton sur la droite, si vous ne pouvez pas être dérangé en utilisant le "Texte" mise en page!)
  • trouver droit de réponse ici. stackoverflow.com/a/52983423/5872337
InformationsquelleAutor rijinrv | 2012-01-24