触摸区域犯规后,移动翻译动画 [英] Touch area doesnt move after translate animation
问题描述
我米使用的 TranslateAnimation ,但是当它得到一张幻灯片,其可触摸面积依然坚持previous位置,它不往下滑布局(具有不同的ImageView),从上到下向下移动一起ImageView的,它显示在视觉上,它的Y轴得到一些价值感动,但它的可触摸面积还在原来的地方。
请帮我解决这个问题。
我已经使用这个滑动动画:
TranslateAnimation T =新TranslateAnimation(0,0,0,35);
t.setDuration(200);
t.setFillAfter(真);
t.setInterpolator(新LinearInterpolator());
menuSlideBgId.startAnimation(T);
inFram.startAnimation(T);
这是我的lyaout文件
<?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT 机器人:重力=左|右
机器人:方向=垂直
机器人:背景=@绘制/ bg_android
>
< ImageView的
机器人:ID =@ + ID / imageView1
机器人:layout_width =150dp
机器人:layout_height =68dp
机器人:layout_gravity =中心
机器人:layout_marginTop =15dp
机器人:SRC =@绘制/ thinknsay/> < RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / rLay
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=垂直>
< ImageView的
机器人:ID =@ + ID / menuSlideBg
机器人:layout_width =339dp
机器人:layout_marginLeft =130dp
机器人:layout_marginTop =452dp
机器人:layout_height =35dp
机器人:SRC =@绘制/ menu_slide3/> < RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:ID =@ + ID / slideNavLayout
机器人:layout_width =match_parent
机器人:layout_height =550dp> < ImageView的
机器人:ID =@ + ID / bubbleMenu
机器人:layout_width =28dp
机器人:layout_height =28dp
机器人:layout_gravity =左
机器人:layout_marginLeft =180dp
机器人:layout_marginTop =455dp
机器人:SRC =@绘制/ buble_icon/> < ImageView的
机器人:ID =@ + ID / shareMenuId
机器人:layout_width =28dp
机器人:layout_height =28dp
机器人:layout_gravity =左
机器人:layout_marginLeft =225dp
机器人:layout_marginTop =455dp
安卓的onClick =shareMenu
机器人:SRC =@绘制/ share_icon/>
< / RelativeLayout的>
< / RelativeLayout的>
< / LinearLayout中>
TranslateAnimation
刚刚重新抽奖在一段时间内不同的位置来看,它并没有真正移动查看
。您还需要改变它的布局位置, ObjectAnimator
可以用来改变查看
属性。
I m sliding down the Layout (which has different ImageView), from top to bottom using TranslateAnimation, but when it get slide, its Touchable area still stick to previous position, it doesnt move downwards along with ImageView, it is showing visually that its Y axis get moved from some value, but its touchable area still at original place.
Please help me in solving this problem.
I have used this for sliding animation :
TranslateAnimation t =new TranslateAnimation(0, 0,0,35);
t.setDuration(200);
t.setFillAfter(true);
t.setInterpolator(new LinearInterpolator());
menuSlideBgId.startAnimation(t);
inFram.startAnimation(t);
This is my lyaout file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left|right"
android:orientation="vertical"
android:background="@drawable/bg_android"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="150dp"
android:layout_height="68dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:src="@drawable/thinknsay" />
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rLay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/menuSlideBg"
android:layout_width="339dp"
android:layout_marginLeft="130dp"
android:layout_marginTop="452dp"
android:layout_height="35dp"
android:src="@drawable/menu_slide3" />
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/slideNavLayout"
android:layout_width="match_parent"
android:layout_height="550dp" >
<ImageView
android:id="@+id/bubbleMenu"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_gravity="left"
android:layout_marginLeft="180dp"
android:layout_marginTop="455dp"
android:src="@drawable/buble_icon" />
<ImageView
android:id="@+id/shareMenuId"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_gravity="left"
android:layout_marginLeft="225dp"
android:layout_marginTop="455dp"
android:onClick="shareMenu"
android:src="@drawable/share_icon" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
TranslateAnimation
just re-draws the view at different positions over time, it doesn't really moves the View
. You need to change its layout position also, ObjectAnimator
can be used to change View
properties.
这篇关于触摸区域犯规后,移动翻译动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!