我使用 TranslateAnimation 从上到下滑动布局(具有不同的ImageView),但是当它滑动时,其可触摸区域仍然保持在先前位置,它不会向下移动使用ImageView,它在视觉上显示其Y轴从某个值移动,但其可触摸区域仍在原始位置。
请帮我解决这个问题。
我用它来滑动动画:
TranslateAnimation t =new TranslateAnimation(0, 0,0,35);
t.setDuration(200);
t.setFillAfter(true);
t.setInterpolator(new LinearInterpolator());
menuSlideBgId.startAnimation(t);
inFram.startAnimation(t);
这是我的lyaout文件
<?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>
答案 0 :(得分:1)
TranslateAnimation
只是随着时间的推移重新绘制不同位置的视图,它并没有真正移动View
。您还需要更改其布局位置,ObjectAnimator
可用于更改View
属性。