android - 如何在 Android 中为其他 ImageView 后面的 ImageView 设置动画

标签 android animation android-animation translate-animation

我在下面显示了两个图像(加号和​​乘号)。单击“加号”图像时,“乘号”图像从“加号”图像的相同位置开始翻译动画,并转到显示在屏幕的末尾附上最后一张图片。我的问题是“乘法”图像在附加的第二张图片中显示的“加号”图像前面设置动画。我想在“加号”图像后面而不是前面设置动画。

我的图像布局 xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent">


<LinearLayout
    android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_marginTop="100dp"
    android:clipChildren="false"
    android:clipToPadding="false">

    <ImageView
        android:id="@+id/plus"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:clipChildren="true"
        android:clipToPadding="true"
        android:scaleType="centerInside"
        android:src="@drawable/plus" />


    <ImageView
        android:id="@+id/multiply"
        android:layout_width="80dp"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:clickable="true"
        android:scaleType="centerInside" />

</LinearLayout>
</LinearLayout> 

enter image description here

enter image description here

enter image description here

最佳答案

只需使用相对布局并稍微改变一下......像这样

<RelativeLayout
    android:id="@+id/parent"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_marginTop="100dp"
    android:clipChildren="false"
    android:clipToPadding="false">

    <ImageView
        android:id="@+id/multiply"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:clickable="true"
        android:src="@android:drawable/btn_star_big_on"
        android:scaleType="centerInside" />

    <ImageView
        android:id="@+id/plus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:clipChildren="true"
        android:clipToPadding="true"
        android:scaleType="centerInside"
        android:src="@android:drawable/btn_star_big_off" />

</RelativeLayout>

enter image description here

关于android - 如何在 Android 中为其他 ImageView 后面的 ImageView 设置动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36517021/

相关文章:

java - 有谁知道为什么我的 map 只显示网格

android - 使用 androidx.preference.PreferenceScreen 和 PreferenceScreen 的区别

android - 使用 MediaCodec API JNI 解码 H.264 流

css - 为什么我的 CSS 动画不工作?

android - 将变形动画从箭头反转为复选标记

android - 如何从 gridView 获取图像(位图)

android - 向下拖动时,Android List View 动画

animation - 流畅的 PostScript 动画

android - 动画之后,使 ImageView 不可见

android - 如何在 onCreate 后立即启动动画?