<?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. Java反射中Class.forName和classloader的区别

    Java中Class.forName和classloader都可以用来对类进行加载. Class.forName除了将类的.class文件加载到jvm中之外,还会对类进行解释,执行类中的static块 ...

  2. P1282 多米诺骨牌[可行性01背包]

    题目来源:洛谷 题目描述 多米诺骨牌有上下2个方块组成,每个方块中有1~6个点.现有排成行的 上方块中点数之和记为S1,下方块中点数之和记为S2,它们的差为|S1-S2|.例如在图8-1中,S1=6+ ...

  3. 网站添加logo图片

    网站添加log图片 第一种方法 这里使用的图片一般为16*16大小的图片 <link rel="shortcut icon" href="http://xxx.xx ...

  4. 前端知识体系:JavaScript基础-作用域和闭包-this的原理以及几种使用场景

    一.问题由来: var obj = { foo: function () { console.log(this.bar) }, bar: 1 }; var foo = obj.foo; var bar ...

  5. 你所不知道的printf函数

    #include <stdio.h> int main(void) { int a = 4; int b = 3; int c = a / b; float d = *(float *)( ...

  6. 基于FPGA自适应串口通信(Auto Baud Rate)

    做的课设,相当于复习了一遍verilog. 实现了 1.接收端固定模式:8N1 BAUD:921600. 2.发送端8N1,任意波特率(不取极端值). 3.数码管显示波特率(16进制). 用了 1.两 ...

  7. appium问题汇总(持续更新。。。)

    WEBVIEW_unknown adb版本较低,adb 1.0.32版本不支持安卓8.x版本,更新adb版本后正常 Install homebrew ruby -e "$(curl -fsS ...

  8. JS 仿支付宝input文本输入框放大组件

    input输入的时候可以在后边显示数字放大镜 <!doctype html> <html lang="en"> <head> <meta ...

  9. SqlProfilter监控指定数据库数据表——监控linq组合查询生成的sql

    1.例子 实际测试环境中往往很多测试都在调用数据库,那么如何使用SqlProfilter监控筛选到自己想要监看的数据库对应的表有关linq生成的sql时候就需要做如下设置了 ........... u ...

  10. HashMap与HashTable的理解与区别

    Hashtable是java一开始发布时就提供的键值映射的数据结构,而HashMap产生于JDK1.2.虽然Hashtable比HashMap出现的早一些,但是现在Hashtable基本上已经被弃用了 ...