Android中的旋转ImageView <API 级别 11 [英] Rotating ImageView in Android < API Level 11

查看:23
本文介绍了Android中的旋转ImageView <API 级别 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,在 API 级别 11 中,Google 引入了旋转 ImageView 的功能(是的,在他们将这种旋转的可能性引入 Animate 之后,是的,聪明的思维,是的!)

So in API Level 11 Google introduced the ability to rotate an ImageView (Yay, after they introduced the possibility to Animate such a rotation, yay smart thinking, yay!)

但是我应该如何使用例如旋转 ImageViewAPI 8 级?如上所述,我不能使用 setRotation().

But how should I go about to rotate an ImageView using e.g. API level 8? I can't use setRotation() as described above.

推荐答案

我从创建位图和旋转画布/矩阵开始,但这不是一个好的解决方案.如果满足条件,最后只是交换可绘制对象.我应该说这是一个 ExpandableListView 单元格在绘图时被重用.

I started with creating BitMap and rotating the canvas/matrix, however this was not a good solution. Finally ended up just swapping the drawable if conditions are met. I should say this is an ExpandableListView where cells are reused when drawing.

if (isExpanded) {
        ImageView view = (ImageView) convertView.findViewById(R.id.ImageView);
        view.setImageResource(R.drawable.quickactions_button_normal_down);
    }

    if (!isExpanded) {
        ImageView view = (ImageView) convertView.findViewById(R.id.ImageView);          
        view.setImageResource(R.drawable.quickactions_button_normal);
    }

我通常不是 Android 开发人员,但我真的很惊讶可以为旋转设置动画,但不能静态设置可绘制对象的旋转.从逻辑上讲,第一个是第二个的子集,而不是相反.

I'm not usually a Android developer but I'm really amazed that it is possible to animate a rotation, but not statically set the rotation of a drawable. Logically the first is a subset of the second and not the other way around.

这篇关于Android中的旋转ImageView <API 级别 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆