我需要将图像保存到手机中的自定义文件夹中.我的代码是
@Override
public void onPictureTaken(byte[] data, Camera camera) {
if (data != null) {
FileOutputStream outStream = null;
try {
Random generator = new Random();
int n = 0000;
n = generator.nextInt(n);
String fName = "Image" + n + ".jpg";
outStream = new FileOutputStream(String.format(fName));
outStream.write(data);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
camera.startPreview();
}
Run Code Online (Sandbox Code Playgroud)
不工作
我正在尝试使用 xml 代码放大图像
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="6000"
android:fromXScale="1dp"
android:fromYScale="1dp"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXScale="150dp"
android:toYScale="150dp"/>
Run Code Online (Sandbox Code Playgroud)
并使用旋转图像
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="4000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360" />
Run Code Online (Sandbox Code Playgroud)
我不能在同一个 xml 中同时使用缩放和旋转。为什么?我该怎么做?