[英]Android: How to only rotate the drawable part of an imageView?
我有一個ImageView對象,其中設置了Background和drawable屬性。 我需要在背景保持靜止的同時為ImageView的可繪制部分設置動畫。
我找不到辦法做到這一點......
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:drawable="@drawable/ic_popup_sync_1"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:duration="1200"
android:toDegrees="360" />
imageView.startAnimation(AnimationUtils.loadAnimation(context,animId));
drawable和background都在同時旋轉......
將背景設置為位於ImageView
后面的單獨布局。 將兩者放入RelativeLayout
,其中背景View
通過左,右,頂部和底部與ImageView
對齊,以便背景保持在圖像的邊界內。 然后您可以自由旋轉圖像。
編輯:
更好的是,但布局中的ImageView
並將布局設置為WRAP_CONTENT
。 將布局的背景設置為背景圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.