-1
A
回答
0
使用下面的方法。
public static Bitmap rotate(Bitmap src, float degree) {
// create new matrix
Matrix matrix = new Matrix();
// setup rotation degree
matrix.postRotate(degree);
// return new bitmap rotated using matrix
return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}
1
隨着API> = 11
mImageView.setRotation(angle)
另一種方法:
ImageView img = (ImageView)findViewById(R.id.yourImageViewId);
Options o = getSize(this, R.drawable.yourImage);
Matrix m = new Matrix();
m.postRotate(angle, o.outWidth/2, o.outHeight/2);
img.setScaleType(ScaleType.MATRIX);
img.setImageMatrix(m);
+0
+爲簡單起見 –
3
你可以創建一個45D的動畫,並把它應用到你的ImageView的,就像這樣:
ImageView image= (ImageView)findViewById(R.id.imageView);
// Create 45d animaion
Animation an = new RotateAnimation(0.0f, 45f, image.getPivotX(), image.getPivotY());
// Set the animation's parameters
an.setDuration(1);
an.setRepeatCount(0);
an.setRepeatMode(Animation.REVERSE);
an.setFillAfter(true);
// Aplly animation to image
image.setAnimation(an);
0
適用於所有API 放置在您的Layout XML中使用ImageView,並在您的Activity的onCreate()中爲其設置動畫:
float rotationDegree = -45; //You can change if you need.
Animation anim = new RotateAnimation(0,rotationDegree);
anim.setFillAfter(true);
imageView.startAnimation(anim);
相關問題
- 1. 顯示矩形中的原始圖像
- 2. 用矩形顯示圖像差異
- 3. 矩形在現有的圖像,然後顯示圖像
- 4. 在矩形或圓形SVG圖像顯示爲黑色
- 5. 在LineChart中顯示矩形
- 6. 在TensorFlow中顯示圖形圖像?
- 7. 矩形中的SSRS圖像/ texboxes不顯示
- 8. 不能得到矩形顯示在圖像的底部
- 9. QML中未顯示矩形
- 10. GridView中的矩形圖像
- 11. 非矩形圖像
- 12. Java矩形圖像
- 13. 非矩形圖像
- 14. 矩形將不會在JFrame中顯示
- 15. 圖像視圖和矩形
- 16. 繪製矩形在Java中顯示像素異常
- 17. 如何在矩形中設置圖像?
- 18. 在圖像中查找白色矩形
- 19. 在圖像中繪製矩形 - Matlab
- 20. 在等矩形圖像中選擇ROI
- 21. Twitter bootsptrap v3攝像頭圖標unicode顯示矩形
- 22. ImagickDraw矩形 - 圖像無法顯示錯誤
- 23. UIImage顯示藍色矩形而不是JPEG圖像
- 24. 如何在iPad中以圖像的形式顯示圖像?
- 25. 使用android camera2在相機預覽和裁剪圖像中顯示矩形2
- 26. 圖像地圖中的高亮矩形
- 27. d3矩形不顯示
- 28. 石英,矩形不顯示
- 29. 矩形邊框不顯示
- 30. Drawables顯示黑色矩形
我看到一個正方形。傾斜在45°... –
http://stackoverflow.com/questions/21002224/add-a-background-image-to-shape-in-xml-android – weston
@BobMalooga廣場是矩形的子類:) –