[英]rotate an image and translate it using xml
我需要這個練習的幫助。 我需要在 xml 文件中插入一個圖像,它必須在前兩秒旋轉,最后必須平移 100,最后圖像必須保持在最終位置。 在 activity_main.xml 我正在嘗試這樣:
<ImageView
android:id="@+id/imageView"
android:rotation="90"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/vEPxtF9" />
這只會旋轉圖像。 是否可以僅使用沒有 java 的 xml 文件來執行此操作?
希望這對你來說足夠好(它有點“只是通過 xml”)
您可以在View
上使用RotateAnimation
。
這是rotation.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="100"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"/>
然后將此動畫提供給您的View
:
Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotation);
myView.startAnimation(rotation);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.