Android-drawable资源-RotateDrawable

            RotateDrawable表示将一个Drawable资源,以平面旋转多少度的后的形式(基于level)。

RotateDrawable的属相介绍:(res/drawable/rotate.xml)

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:visible="true"                      //是否可见
    android:fromDegrees="0"                     //从多少度开始选装   
    android:toDegrees="90"                      //到多少度结束,其实随着level的增加,图片可以一直旋转
    android:pivotX="50%"                        //旋转中心的x坐标
    android:pivotY="50%"                        //选装中心的y坐标
    android:drawable="@drawable/aa">            //指定drawable资源文件
    

</rotate>

引用:

<ImageView 
        android:id="@+id/iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@null"
        android:src="@drawable/rotate"/>

让Drawable资源图片,每点击一下顺时针旋转。

ImageView iv=(ImageView) findViewById(R.id.iv);
		final RotateDrawable rotateDrawable=(RotateDrawable) iv.getDrawable();
		rotateDrawable.setLevel(1);
		iv.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				rotateDrawable.setLevel(rotateDrawable.getLevel()+1000);
			}
		});








评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值