相关疑难解决方法(0)

如何在Android中进行流畅的图像旋转?

我正在使用a RotateAnimation来旋转我在Android中用作自定义循环微调器的图像.这是我的rotate_indefinitely.xml文件,我放入res/anim/:

<?xml version="1.0" encoding="UTF-8"?>
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:duration="1200" />    
Run Code Online (Sandbox Code Playgroud)

当我将它应用于我的ImageView使用时AndroidUtils.loadAnimation(),效果很好!

spinner.startAnimation( 
    AnimationUtils.loadAnimation(activity, R.anim.rotate_indefinitely) );
Run Code Online (Sandbox Code Playgroud)

一个问题是图像旋转似乎在每个周期的顶部暂停.

换句话说,图像旋转360度,暂停,然后再旋转360度等.

我怀疑问题是动画是使用像android:iterpolator="@android:anim/accelerate_interpolator"(AccelerateInterpolator)的默认插值器,但我不知道如何告诉它不插入动画.

如何关闭插值(如果这确实是问题)以使我的动画循环顺利进行?

animation android view

209
推荐指数
10
解决办法
22万
查看次数

Android:以一定角度在imageview中旋转图像

我使用以下代码在ImageView中旋转图像一个角度.有没有更简单,更简单的方法可用.

ImageView iv = (ImageView)findViewById(imageviewid);
TextView tv = (TextView)findViewById(txtViewsid);
Matrix mat = new Matrix();
Bitmap bMap = BitmapFactory.decodeResource(getResources(),imageid);
mat.postRotate(Integer.parseInt(degree));===>angle to be rotated
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,bMap.getWidth(),bMap.getHeight(), mat, true);
iv.setImageBitmap(bMapRotate);
Run Code Online (Sandbox Code Playgroud)

android bitmap rotation imageview

147
推荐指数
9
解决办法
28万
查看次数

标签 统计

android ×2

animation ×1

bitmap ×1

imageview ×1

rotation ×1

view ×1