摘要:本文将带你了解Android源码之渐变动画的实现,希望本文对大家学Android有所帮助。
android动画之AlphaAnimation(渐变动画,最简单的动画)
AlphaAnimation渐变动画只需要设置从一可见程度,到另一可见程度即可。
示例代码:
package com.hongchou.www.myalphaanimation; import android.app.Activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Window; import android.view.animation.AlphaAnimation; import android.widget.ImageView; /** * android AlphaAnimation渐变动画 */ public class MainActivity extends Activity { private ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); iv = findViewById(R.id.iv); AlphaAnimation alphaAnimation=new AlphaAnimation(0,1); alphaAnimation.setDuration(2000); iv.startAnimation(alphaAnimation); } } 布局文件代码: <!--?xml version="1.0" encoding="utf-8"?--> <imageview android:background="@drawable/bk" android:id="@+id/iv" android:layout_height="match_parent" android:layout_width="match_parent" android:text="Hello World!" app:layout_constraintbottom_tobottomof="parent" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent"> </imageview></android.support.constraint.constraintlayout>
注意设置动画时间,才能看到动画效果
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之Android频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号