1.介绍

补间动画开发者只需指定动画开始,以及动画结束"关键帧", 而动画变化的"中间帧"则由系统计算并补齐!

2.去掉App的标题

(1)将AndroidManifest文件中Application标签中内容保持不变。

android:theme="@style/AppTheme"(即默认设置).

(2)修改values->styles.xml中的设置

将以下内容:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

替换为:

<resources>

    <!-- Base application theme. -->
<!--<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style> </resources>

3.修改应用显示的图标

AndroidManifest文件中,将以下代码进行修改。

(1)修改前

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

(2)修改后

<application
android:allowBackup="true"
android:icon="@mipmap/icon_150"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

4.XML布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"> <Button
android:id="@+id/bt_touming"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="透明" /> <Button
android:id="@+id/bt_xuanzhuan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="旋转" /> <Button
android:id="@+id/bt_suofang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="缩放" /> </LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"> <ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>

5.java后台

package com.example.administrator.test60donghua;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.widget.Button;
import android.widget.ImageView; public class MainActivity extends AppCompatActivity { Button bt_touming;
Button bt_xuanzhuan;
Button bt_suofang;
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt_touming=findViewById(R.id.bt_touming);
bt_xuanzhuan=findViewById(R.id.bt_xuanzhuan);
bt_suofang=findViewById(R.id.bt_suofang);
iv=findViewById(R.id.imageView); //透明动画
bt_touming.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//创建透明动画,1.0为完全不透明,0.0为完全透明
AlphaAnimation aa=new AlphaAnimation(1.0f,0.0f);
aa.setDuration(2000);//设置动画执行的时间
aa.setRepeatCount(1); //设置动画重复的次数
aa.setRepeatMode(Animation.REVERSE); //设置重复的模式
iv.startAnimation(aa); //开始执行动画
}
}); //旋转效果
bt_xuanzhuan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RotateAnimation ra=new RotateAnimation(0,360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
ra.setDuration(2000);//设置动画执行的时间
ra.setRepeatCount(1); //设置动画重复的次数
ra.setRepeatMode(Animation.REVERSE); //设置重复的模式
iv.startAnimation(ra); //开始执行动画
}
}); bt_suofang.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ScaleAnimation sa=new ScaleAnimation(1.0f,2.0f,1.0f,2.0f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
sa.setDuration(2000);//设置动画执行的时间
sa.setRepeatCount(1); //设置动画重复的次数
sa.setRepeatMode(Animation.REVERSE); //设置重复的模式
iv.startAnimation(sa); //开始执行动画
}
}); }
}

6.效果图

最新文章

  1. 【转】mysql_fetch_row , mysql_fetch_array , mysql_fetch_assoc 的区别
  2. 搭建maven开发环境测试Hadoop组件HDFS文件系统的一些命令
  3. C#读取Excel表中的数据时,为何有些行的字段内容读取不到
  4. Duff in Love - 588B(素数的判断)
  5. java 基础知识
  6. BIEE11g BI_server Jvm參数调整
  7. FLOYD 求最小环
  8. 对Bitmap的内存优化
  9. Android tabLayout+recyclerView实现锚点定位
  10. 编程一小时 code.org [六一关注]
  11. B. Divisor Subtraction
  12. 『转载』hadoop 1.X到2.X的变化
  13. eclipse中选中一个单词 其他相同的也被选中 怎么设置
  14. JavaWeb:c3p0配置问题java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
  15. 一张图让你学会Python
  16. 继承方法--&gt;call继承
  17. CentOS VNC
  18. Java 实时论坛 - Sym 1.4.0 发布
  19. Away3D引擎学习笔记(三)模型拾取(翻译)
  20. Arduino学习笔记A6(补充) - 在串口读取多个字符串,并且转换为数字数组

热门文章

  1. jmeter五种提取器 之 正则表达式
  2. ZR#984
  3. X-NUCA-ezphp记录
  4. AAR文件简介
  5. 方法重载与invokevirtual字节码指令的关系
  6. JVM 扩展类加载器1
  7. Java 自动装箱/拆箱
  8. REDIS中加锁和解锁问题
  9. vue-router 使用query传参跳转了两次(首次带参数,跳转到了不带参数)
  10. 006 GET API