<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
tools:context="com.loaderman.customviewdemo.MainActivity"> <TableLayout
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"> <TableRow> <Button
android:id="@+id/start_alpha"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="alpha"/> <Button
android:id="@+id/start_rotation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rotation"/> <Button
android:id="@+id/start_rotationX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rotationX"/> </TableRow> <TableRow> <Button
android:id="@+id/start_rotationY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rotationY"/> <Button
android:id="@+id/start_translationX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="translationX"/> <Button
android:id="@+id/start_translationY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="translationY"/>
</TableRow> <TableRow> <Button
android:id="@+id/start_scaleX"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="scaleX"/> <Button
android:id="@+id/start_scaleY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="scaleY"/> </TableRow>
</TableLayout> <TextView
android:visibility="gone"
android:id="@+id/tv"
android:layout_marginLeft="30dp"
android:layout_width="50dp"
android:layout_height="20dp"
android:gravity="center"
android:text="启舰"
android:layout_marginTop="100dp"
android:layout_gravity="center"
android:background="#000000"
android:textColor="#ffffff"/> <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"> <Button
android:id="@+id/demobtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start anim"/> <com.loaderman.customviewdemo.CustomTextView
android:id="@+id/customtv"
android:layout_toRightOf="@id/demobtn"
android:layout_marginLeft="30dp"
android:layout_width="50dp"
android:layout_height="20dp"
android:gravity="center"
android:text="Hello"
android:background="#000000"
android:textColor="#ffffff"/> </RelativeLayout> </LinearLayout>
package com.loaderman.customviewdemo;

import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView; public class MainActivity extends AppCompatActivity {
private TextView tv; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); final CustomTextView tv2 = (CustomTextView) findViewById(R.id.customtv);
findViewById(R.id.demobtn).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
ObjectAnimator animator = ObjectAnimator.ofFloat(tv2, "ScaleSize", 6);
animator.setDuration(2000);
animator.start();
}
}); tv = (TextView) findViewById(R.id.tv); findViewById(R.id.start_alpha).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* 实现alpha值变化
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "alpha", 1, 0, 1);
animator.setDuration(2000);
animator.start();
}
}); findViewById(R.id.start_rotation).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* Z轴旋转
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "rotation", 0, 270, 0);
animator.setDuration(2000);
animator.start();
}
}); findViewById(R.id.start_rotationX).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* RotationX旋转
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "rotationX", 0, 270, 0);
animator.setDuration(2000);
animator.start();
}
}); findViewById(R.id.start_rotationY).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* RotationY 旋转
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "rotationY", 0, 180, 0);
animator.setDuration(2000);
animator.start(); }
}); findViewById(R.id.start_translationX).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* translationX动画
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "translationX", 0, 200, -200, 0);
animator.setDuration(2000);
animator.start();
}
}); findViewById(R.id.start_translationY).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* translationY动画
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "translationY", 0, 200, -100, 0);
animator.setDuration(2000);
animator.start();
}
}); findViewById(R.id.start_scaleX).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/**
* scaleX缩放动画
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "scaleX", 0, 3, 1);
animator.setDuration(2000);
animator.start();
}
}); findViewById(R.id.start_scaleY).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { /**
* scaleY缩放动画
*/
ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "scaleY", 0, 3, 1);
animator.setDuration(2000);
animator.start();
}
});
}
}
package com.loaderman.customviewdemo;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView; public class CustomTextView extends TextView {
public CustomTextView(Context context) {
super(context);
} public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
} public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
} public void setScaleSize(float num){
setScaleX(num);
} public float getScaleSize(){
return 0.5f;
}
}

效果:

ObjectAnimator简单示例的更多相关文章

  1. Linux下的C Socket编程 -- server端的简单示例

    Linux下的C Socket编程(三) server端的简单示例 经过前面的client端的学习,我们已经知道了如何创建socket,所以接下来就是去绑定他到具体的一个端口上面去. 绑定socket ...

  2. C# 构建XML(简单示例)

    C# 构建XML的简单示例: var pars = new Dictionary<string, string> { {"url","https://www. ...

  3. 根据juery CSS点击一个标签弹出一个遮罩层的简单示例

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  4. ACEXML解析XML文件——简单示例程序

    掌握了ACMXML库解析XML文件的方法后,下面来实现一个比较完整的程序. 定义基本结构 xml文件格式如下 <?xml version="1.0"?> <roo ...

  5. demo工程的清单文件及activity中api代码简单示例

    第一步注册一个账户,并创建一个应用.获取app ID与 app Key. 第二步下载sdk 第三步新建工程,修改清单文件,导入相关的sdk文件及调用相应的api搞定. 3.1 修改清单文件,主要是加入 ...

  6. spring-servlet.xml简单示例

    spring-servlet.xml简单示例 某个项目中的spring-servlet.xml 记下来以后研究用 <!-- springMVC简单配置 --> <?xml versi ...

  7. SignalR 简单示例

    一.什么是 SignalR ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of add ...

  8. Web API 简单示例

    一.RESTful和Web API Representational State Transfer (REST) is a software architecture style consisting ...

  9. XML引入多scheme文件约束简单示例

    XML引入多scheme文件约束简单示例,用company.xsd和department.xsd来约束company.xml: company.xsd <?xml version="1 ...

随机推荐

  1. WebClient 与HttpClient 的区别

    需要搜索下资料. -------------------------------------------------- 微软文档介绍,新的开发中推荐使用:HttpClient WebClient 文档 ...

  2. Win10 hosts文件无法保存

    Win10无法修改编辑保存hosts文件怎么办?Win10系统默认是没有权限去编辑保存系统里的文件,这也是权限不够才导致修改编辑hosts后无法保存的原因,解决的办法就是把自己的帐户权限给提高就行了. ...

  3. Listener中@Autowired无法注入的问题

    最近在用监听器的时候遇到了spring无法注入的问题,代码如下,这个task总是null,包明明已经被扫到了,就是注入不进来. public class MyListener implements S ...

  4. fiddler修改请求和返回

    一.修改请求 1.先设置请求前断点 2.设置拦截,在左下角的QuickExec命令行中输入bpu www.baidu.com/XXXX 3.选中需要修改的请求,选中Inspectors面板,使用Raw ...

  5. 是什么是FBC CBV

    - FBV url   -   函数 - CBV url   -   view

  6. php MySQL 删除数据表

    MySQL 删除数据表 MySQL中删除数据表是非常容易操作的, 但是你再进行删除表操作时要非常小心,因为执行删除命令后所有数据都会消失. 语法 以下为删除MySQL数据表的通用语法: DROP TA ...

  7. Elasticsearch 使用:创建、插入、查询、更新、删除

    Elasticsearch 是一个开源的搜索引擎,建立在一个全文搜索引擎库 Apache Lucene™ 基础之上. Lucene 可能是目前存在的,不论开源还是私有的,拥有最先进,高性能和全功能搜索 ...

  8. 四十二.部署MongoDB服务 、 MongoDB基本使用

    1. 部署MongoDB服务  192.168.4.50 创建服务工作目录 ]# mkdir /usr/local/mongodb ]# cd /usr/local/mongodb/ ]# mkdir ...

  9. public abstract啥时候可以省略?

    父类是抽象类,其中有抽象方法,那么子类继承父类,并把父类中的所有方法都实现覆盖了,子类才有创建对象实例的能力,否则子类也必须是抽象类.抽象类中可以有构造方法,是子类在构造子类对象时需要调用父类(抽象类 ...

  10. java+web+下载断点续传

    1.先将 webuploader-0.1.5.zip 这个文件下载下来:https://github.com/fex-team/webuploader/releases  根据个人的需求放置自己需要的 ...