android:layout_weight=“1”
android:background=“#9c98ce”
android:orientation=“vertical”
android:paddingLeft=“20dp”
android:paddingRight=“20dp”
android:paddingTop=“10dp”>
<Button
android:id=“@+id/button”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:background=“#5b7bda”
android:text=“点击演示动画”
android:textColor=“#fff” />
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“0dp”
android:layout_weight=“4”
android:orientation=“vertical”>
<ImageView
android:id=“@+id/image”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center”
android:layout_marginTop=“20dp”
android:background=“@mipmap/kuiba” />
<TextView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center”
android:text=“《魁拔》”
android:textSize=“18sp” />
代码逻辑 篇
属性动画用到的是:ObjectAnimator
package com.example.text.shuxingdonghua;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
ObjectAnimator objectAnimator;
private Button button;
private ImageView image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
button = (Button) findViewById(R.id.button);
image = (ImageView) findViewById(R.id.image);
button.setOnClickListener(this);
image.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button:
objectAnimator = ObjectAnimator.ofFloat(image,“rotation”,360f);
objectAnimator.setDuration(2000);
objectAnimator.start();
break;
case R.id.image:
Toast.makeText(this, “我是属性动画”, Toast.LENGTH_SHORT).show();
break;
}
}
}
AndroidStudio快速实例化-插件安装与使用:https://blog.csdn.net/qq_40881680/article/details/82012180
objectAnimator = ObjectAnimator.ofFloat(image,“rotation”,360f);
将图片旋转360度,只有一次效果
objectAnimator = ObjectAnimator.ofFloat(image,“rotation”,0f,360f);
将图片,从初始值0度,顺时针转360度
objectAnimator = ObjectAnimator.ofFloat(image,“rotation”,0f,360f,0f);
将图片,从初始0度,顺时针旋转360度,再逆时针旋转360度到0度
ObjectAnimator.ofFloat()括号中的参数:
第一个参数,要实现动画的控件id
第二个参数,要实现的动画属性,以下列出6种:
|
propertyName
| 详细作用 |
| — | — |
| alpha | 实现渐变效果 |
| rotation | 实现旋转旋转效果 |
| translationX | 实现水平移动效果(左或右移动) |
| translationY | 实现纵向移动效果(向上或者向下移动) |
| scaleX | 实现轴X缩放效果(放大或者缩小) |
| scaleY | 实现轴Y缩放效果(放大或者缩小) |
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
尾声
在我的博客上很多朋友都在给我留言,需要一些系统的面试高频题目。之前说过我的复习范围无非是个人技术博客还有整理的笔记,考虑到笔记是手写版不利于保存,所以打算重新整理并放到网上,时间原因这里先列出面试问题,题解详见:
展示学习笔记
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
的复习范围无非是个人技术博客还有整理的笔记,考虑到笔记是手写版不利于保存,所以打算重新整理并放到网上,时间原因这里先列出面试问题,题解详见:
[外链图片转存中…(img-kKdjKTIE-1712155944426)]
展示学习笔记
[外链图片转存中…(img-xfx9PTNd-1712155944426)]
[外链图片转存中…(img-5B0pIgu6-1712155944426)]