-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广场是矩形的子类:) –