我有两个网格视图,我想为其创建自定义动画.想象一下这个布局:
___________________________________________ | | | | | TOP Grid | | | |_________________________________________| | | | | | BOTTOM | | Grid | | | |_________________________________________|
底部网格将在顶部网格后面"滑出"和"滑动".我想我应该使用翻译动画.如何找出fromX和fromY值?我以为我可以同时在布局中查看,然后将动画设置为RelativeToParent.
这是正确的方法吗?如果您知道任何地方我可以找到此功能的源代码,我将非常感激.谢谢,
我有一个有趣的问题......我似乎无法找到解决方案.我正在使用ObjectAnimator来旋转ImageView; 但onTouchListener似乎只是注册了MotionEvent.ACTION_DOWN.(我从Log Cats中推断出这个,还有MotionEvent.ACTION_MOVE和MotionEvent.ACTION_UP).
我想也许问题可能与试图同时倾听和动画片有关.我在相对布局中包装了imageview和线性布局(设置为MATCH PARENT),并注册了线性布局以监听触摸事件.线性布局具有相同的问题; 只处理MotionEvent.ACTION_UP.有什么东西我需要去注册MotionEvent.ACTION_MOVE吗?
这是我的代码:
touch_pad = (LinearLayout) findViewById(R.id.layout_touch_capture);
touch_pad.setOnTouchListener(this);
touch_pad.requestFocus();
public boolean onTouch(View v, MotionEvent event) {
switch(v.getId()) {
case (R.id.layout_touch_capture):
long end = 0;
long start = 0;
float y = event.getY();
float y_sum = y;
float x = event.getX();
switch(event.getAction()) {
case (MotionEvent.ACTION_UP):
end = animator.getCurrentPlayTime();
Log.d("WheelActivity", "end location = " + end);
break;
case (MotionEvent.ACTION_MOVE):
Log.d("WheelActivity", "event.getY() = " + y);
y_sum += y;
animator.setCurrentPlayTime((long) (start + y_sum));
Log.d("WheelActivity", "animator play time = " …Run Code Online (Sandbox Code Playgroud)