zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

android图片透明度跟缩放大小动画事件

Android事件动画 图片 大小 缩放 透明度
2023-09-14 08:57:56 时间

概序 : 动画事件写在xml中,然后用AnimationUtils去加载动画事件,再监听动画结束事件,隐藏imageview。


1. player_double_click_animation.xml 动画文件


?xml version="1.0" encoding="utf-8"?    set xmlns:android="http://schemas.android.com/apk/res/android"          alpha           android:duration="800"           android:fromAlpha="0.1"           android:toAlpha="1.0"/         scale           android:duration="800"           android:fillAfter="false"           android:fromXScale="0.2"           android:fromYScale="0.2"           android:interpolator="@android:anim/accelerate_decelerate_interpolator"           android:pivotX="50%"           android:pivotY="50%"           android:toXScale="1.0"           android:toYScale="1.0"/    /set   
android:fromAlpha="1.0" //这是表示动画一开始是完全不透明

android:toAlpha="0.0" //这是表示动画结果时是完全透明

android:duration="500" //这是动画的时间

scale参数说明:

float fromX 动画起始时 X坐标上的伸缩尺寸 
float toX 动画结束时 X坐标上的伸缩尺寸   
float fromY 动画起始时Y坐标上的伸缩尺寸  
float toY 动画结束时Y坐标上的伸缩尺寸  
int pivotXType 动画在X轴相对于物件位置类型  
float pivotXValue 动画相对于物件的X坐标的开始位置   
int pivotYType 动画在Y轴相对于物件位置类型   
float pivotYValue 动画相对于物件的Y坐标的开始位置  


2.布局文件test_aniamtion.xml


?xml version="1.0" encoding="utf-8"?    LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       android:layout_width="match_parent"       android:layout_height="match_parent"       android:orientation="vertical"          Button           android:id="@+id/click"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:text="点击我" /         ImageView           android:id="@+id/like"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:layout_gravity="center"           android:src="@drawable/icon_video_double_click"           android:visibility="gone" /    /LinearLayout   
    protected void onCreate(Bundle savedInstanceState) {           super.onCreate(savedInstanceState);           setContentView(R.layout.test_aniamtion);           findViewById(R.id.click).setOnClickListener(listener);           imageView=(ImageView) findViewById(R.id.like);       }              private OnClickListener listener=new OnClickListener() {           @Override           public void onClick(View v) {               imageView.setVisibility(View.VISIBLE);               //加载动画               Animation animation=AnimationUtils.loadAnimation(MainActivity.this,R.anim.player_double_click_animation);               imageView.startAnimation(animation);//开始动画               animation.setAnimationListener(new AnimationListener(){                   @Override                   public void onAnimationStart(Animation animation) {}                   @Override                   public void onAnimationRepeat(Animation animation) {}                   @Override                   public void onAnimationEnd(Animation animation) {//动画结束                       imageView.setVisibility(View.GONE);                   }               });           }       };  
Android 基础动画之 alpha 透明度 / translate 平移 / rotate 旋转  小菜最近在学习 Android 基本动画,前两天整理了一下相对复杂的 Android 基础动画之 scale 渐变缩放,今天继续学习整理其他三种基本动画。 公共属性: 1. android:duration= 3500  duration 代表动画过程中持续时常;所有的动画均有该属性; 2. android:fillAfter= true  fillAfter 代表动画结束后是否保存在最后位置,true 为结束位置,false 为返回开始位置。
Android/iOS及设计中ARGB颜色值百分比透明度换算 设计上经常要求对一个颜色值进行一定百分比的透明度,比如给定一个颜色0xFF0000FF(蓝色)要求80%透明,该如何处理呢?80%透明的蓝色值是多少呢?常见的颜色是RGB表示的,就比如上面的蓝色0xFF0000FF,这个颜色值是16进制表示的,其中0x后面接着的两个16进制数字‘FF’就是ARGB中的‘A’,即alpha。
Android 计算布局背景的透明度 1、#ff000000 此为16进制颜色代码,前2位ff为透明度,后6位为颜色值(000000为黑色,ffffff为白色,可以用ps等软件获取)。 2、透明度分为256阶(0-255),计算机上用16进制表示为(00-ff)。
Android StatusBarUtil是github上的一个开源项目,主页:https://github.com/laobie/StatusBarUtil StatusBarUtil可以修改Android底部下方系统的原生虚拟键键盘的透明度。
ansen_666 有三年android开发经验,开发过加密.短视频.直播app,一直在互联网公司工作,目前就职于上海翼成科技,担任android开发组长。