簡體   English   中英

Android:如何只旋轉imageView的可繪制部分?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM