Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中的从右向左平移动画问题_Android_Animation - Fatal编程技术网

Android中的从右向左平移动画问题

Android中的从右向左平移动画问题,android,animation,Android,Animation,我有一个问题,动画的形象,放置在外的权利或底部边界的父布局 此图像在动画播放时进行裁剪 第一个图像是原始图像,第二个图像看起来应该是相同的,但由于图像的一部分位于右边框之外而被裁剪 底部边界的情况相同 动画: public void onClickDo(View view) { ImageView img = (ImageView) findViewById(R.id.imageView2); TranslateAnimation anim = new TranslateAn

我有一个问题,动画的形象,放置在外的权利或底部边界的父布局

此图像在动画播放时进行裁剪

第一个图像是原始图像,第二个图像看起来应该是相同的,但由于图像的一部分位于右边框之外而被裁剪

底部边界的情况相同

动画:

public void onClickDo(View view) {
    ImageView img = (ImageView) findViewById(R.id.imageView2);

    TranslateAnimation anim = new TranslateAnimation(0f, -100f, 0f, 0f);
    anim.setDuration(1000);

    img.startAnimation(anim);
}
布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <RelativeLayout android:layout_width="fill_parent" android:id="@+id/relativeLayout1" android:layout_height="wrap_content">
        <ImageView android:id="@+id/imageView1" android:src="@drawable/problem" android:layout_width="100dip" android:layout_height="100dip"></ImageView>
        <ImageView android:id="@+id/imageView2" android:src="@drawable/problem" android:layout_height="100dip" android:layout_width="100dip" android:layout_marginLeft="250dip" android:scaleType="matrix" android:layout_marginTop="110dip"></ImageView>
        <Button android:layout_alignParentBottom="true" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button1" android:text="Button" android:onClick="onClickDo"></Button>
    </RelativeLayout>
</LinearLayout>

尝试使用android:layout\u alignParentRight=“true”查看图像2

<ImageView android:id="@+id/imageView2" android:src="@drawable/problem" android:layout_height="100dip" android:layout_width="100dip" android:scaleType="matrix" android:layout_alignParentRight="true" android:layout_toRightOf="@+id/imageView1"></ImageView>

当我有两个对象(布局、视图等)共享同一个动画时,我遇到了类似的问题

例如:

Image1.startAnimation(myAnimation);
Image2.startAnimation(myAnimation);
和myAnimation具有
setAnimationListener
,其中设置了
onAnimationEnd


因此,即使你一个接一个地启动动画,其他安卓系统也会有问题,而且会变得滞后。

为你的线性布局和相对布局都这样做:

android:clipChildren="false"
要以编程方式执行此操作,请执行以下操作:

myLinearLayout.setClipChildren(false);
myRelativeLayout.setClipChildren(false);

它将图像放在第一个图像的右边,但我希望初始图像位置应该在边界之外。这样如何,将视图的初始可见性设置为不可见。为动画对象设置animationlistener,然后在动画结束时将imageview的可见性设置为可见