AnimatedRotateDrawable的简单使用

本篇是关于Drawable的第十二篇博客了,我都不知怎么介绍这个Drawable,只能说是自带旋转动画特效,如果你使用了AnimatedRotateDrawable作为背景,背景的绕着指定的旋转中心进行旋转。如果没有设置的话,旋转中心为drawable的左上角坐标。AnimatedRotateDrawable这个类很奇怪,不能直接在代码中使用,这个类使用@hide注释,第三方应用只能通过xml声明AnimatedRotateDrawable。好了,废话不多说了,直接看效果吧!
图片旋转tupai

主布局文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.animatedrotatedrawable.MainActivity">

    <TextView
        android:layout_centerInParent="true"
        android:gravity="center"
        android:background="@drawable/animated_rotate_drawable"
        android:id="@+id/tv"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:text="Hello World!" />
</RelativeLayout>

animated_rotate_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:pivotX="50%"
    android:pivotY="50%"
    android:drawable="@drawable/fifth">
</animated-rotate>

其中pivotX、pivotY用于指定旋转中心的位置,50%代表的是宽/高的一半,在这个实例中代表的就是drawable的中心点位置。

java文件就不给出来了,默认生成的java文件就行了!!

这是我的微信公众号,如果可以的话,希望您可以帮忙关注一下,这将是对我最大的鼓励了,谢谢!!

公众号

代码地址:
AnimatedRotateDrawable地址,地址比较杂,需要您自行提取!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值