Android View -- setTranslationX】的更多相关文章

通过此方法使View位置发生偏移,达到margin的作用却又不改变View的getLeft()的值. 恢复方法是setTranslationX(0),而不是上一次偏移量的相反数. 不过,通过getLocationInWindow(), getLocationOnScreen()获取到的位置是发生变化的,因此才能看到View的移动. 参考:Android动画精讲一:从setTranslationX谈属性动画和view动画的区别…
参考: 1.Android Matrix理论与应用详解 2.2D平面中关于矩阵(Matrix)跟图形变换的讲解 3.Android中关于矩阵(Matrix)前乘后乘的一些认识 4.Android Matrix View.setPivotX:设置旋转或缩放的基点的X位置,默认是对象的中点(官方API说明:https://developer.android.com/reference/android/view/View.html#setPivotX(float)). View.setScaleX:设…
Animation TypeEvaluator View的animate方法 ValueAnimator ObjectAnimator AnimatorSet 使用xml来创建动画 animation objectAnimator set Animator set 自己定义ObjectAnimator属性 propertyValuesHolder Keyframe Interpolator 贝塞尔曲线 PathInterpolator 加减速引子 Android的动画模式:tween anima…
* This class represents the basic building block for user interface components. A View * occupies a rectangular area on the screen and is responsible for drawing and * event handling. View is the base class for <em>widgets</em>, which are * us…
本文结合一些周知的概念和源码片段,对View动画的工作原理进行挖掘和分析.以下不是对源码一丝不苟的分析过程,只是以搞清楚Animation的执行过程.如何被周期性调用为目标粗略分析下相关方法的执行细节,最终贯穿View动画实际发生的一切. View动画使用 Android提供了属性动画(property animation).帧动画(frame-by-frame animation)和View动画( tweened animation:补间动画),View动画的使用相对简单,但又不像真正意义上的…
Android View.setId(int id) 用法 当要在代码中动态的添加View并且为其设置id时,如果直接用一个int值时,Studio会警告. 经过查询,动态设置id的方法有两种; 1. View.generateViewId(); 这个方法的返回值是个int值,方法的意思是获取一个可以用在setId(int id)方法中的int类型id; 官方文档说明: int generateViewId () Added in API level 17 Generate a value su…
这个就好像是 activity 的生命周期一样,如果我们要使用自定义的 view,那么就很有必要了解一下 view 的那些能够被重写的函数的执行顺序.废话不多讲,以常用的5个函数为例子,见下文: package com.example.pulltorefreshtest; import android.content.Context; import android.graphics.Canvas; import android.util.AttributeSet; import android.…
这个错误也是让我纠结了一天,当时写的项目在安卓虚拟机上运行都很正常,于是当我部署到安卓手机上时,点击登陆按钮跳转到用户主界面的时候直接结束运行返回登陆界面.    当时,我仔细检查了一下自己的代码,并没有发现什么问题,在logcat上显示的报错如下:AndroidRuntime:android.view.InflateException: Binary XML file line #168: Error inflating class(这是其中报错的最主要的一行信息).  于是我在百度上几乎查看…
一直想写事件分发机制的文章,不管咋样,也得自己研究下事件分发的源码,写出心得~ 首先我们先写个简单的例子来测试View的事件转发的流程~ 1.案例 为了更好的研究View的事件转发,我们自定以一个MyButton继承Button,然后把跟事件传播有关的方法进行复写,然后添加上日志~ MyButton package com.example.zhy_event03; import android.content.Context; import android.util.AttributeSet;…
2015-07-28 17:29:19 这一篇主要看看布局过程 一.布局过程肯定要不可避免的涉及到layout()和onLayout()方法,这两个方法都是定义在View.java中,源码如下: /** * Assign a size and position to a view and all of its * descendants * * <p>This is the second phase of the layout mechanism. * (The first is measur…