一、PPT旋轉動畫
1、在 PowerPoint 中打開需要添加旋轉動畫的幻燈片,選中想要旋轉的形狀或圖片。
2、點擊「動畫」選項卡,在「效果」下拉菜單中選擇「旋轉」。
3、在「旋轉」下拉菜單中選擇「雙向旋轉」或「單向旋轉」,並設置旋轉的度數。
//示例代碼 AnimationSet set = new AnimationSet(true); RotateAnimation rotate = new RotateAnimation(fromDegrees, toDegrees, pivotXType, pivotXValue, pivotYType, pivotYValue); set.addAnimation(rotate);
二、Android圖片旋轉動畫
1、在drawable文件夾中添加需要旋轉的圖片。
2、在xml文件中添加ImageView,並設置旋轉動畫的屬性。
<ImageView android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image" android:rotation="45" android:pivotX="50%" android:pivotY="50%"/>
3、在java文件中獲取ImageView,並使用AnimatorSet設置旋轉動畫。
ImageView imageView = findViewById(R.id.imageview); ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(imageView, "rotation", 0f, 360f); rotateAnimator.setDuration(1000); rotateAnimator.setRepeatCount(ValueAnimator.INFINITE); rotateAnimator.setRepeatMode(ValueAnimator.RESTART); AnimatorSet set = new AnimatorSet(); set.playTogether(rotateAnimator); set.start();
三、Flash旋轉動畫怎麼做
1、在Flash中添加需要旋轉的圖片或動畫。
2、在「時間軸」上選擇需要添加旋轉動畫的幀數。
3、點擊「插入」選項卡,在「形狀」下拉菜單中選擇「形狀運動」並設置旋轉角度。
//示例代碼 this.myTween = new flash.display.Tween(this, "rotation", Strong.easeInOut, 0, 360, 4, true);
四、Android頁面跳轉動畫
1、在res文件夾中創建anim文件夾,添加需要使用的動畫文件。
2、在java文件中使用overridePendingTransition方法設置跳轉動畫。
Intent intent = new Intent(MainActivity.this, SecondActivity.class); startActivity(intent); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
五、Android屏幕旋轉
1、在AndroidManifest.xml文件中添加screenOrientation屬性。
2、設置activity的screenOrientation為「portrait」或「landscape」。
<activity android:name=".MainActivity" android:screenOrientation="portrait" />
六、Android獲取圖片旋轉角度
1、在java文件中獲取圖片的exif信息。
2、通過exif信息獲取旋轉角度。
//示例代碼 ExifInterface exif = new ExifInterface(filepath); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int degree = 0; switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_90: degree = 90; break; case ExifInterface.ORIENTATION_ROTATE_180: degree = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: degree = 270; break; }
七、Android View旋轉
1、在java文件中獲取需要旋轉的View。
2、使用ObjectAnimator設置View的旋轉屬性。
//示例代碼 View view = findViewById(R.id.myview); ObjectAnimator rotateAnimator = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f); rotateAnimator.setDuration(1000); rotateAnimator.start();
八、Android Bitmap旋轉
1、在java文件中獲取需要旋轉的Bitmap。
2、使用Matrix設置Bitmap的旋轉屬性。
//示例代碼 Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.image); Matrix matrix = new Matrix(); matrix.postRotate(90); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
九、Android禁止屏幕旋轉
1、在AndroidManifest.xml文件中添加screenOrientation屬性。
2、設置activity的screenOrientation為「portrait」。
<activity android:name=".MainActivity" android:screenOrientation="portrait" />
原創文章,作者:NKZPK,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/331212.html