对视图进行动画处理会使其在Android屏幕上消失

问题描述

我正在尝试为定义如下的视图制作动画:

headView = LayoutInflater.from(this).inflate(R.layout.head,null);

R.layout.head就像:

<RelativeLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="65dp"
    android:layout_height="wrap_content"
    android:id="@+id/head">

    <androidx.appcompat.widget.AppCompatImageView
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:id="@+id/head_image"
        android:src="@mipmap/ic_launcher_round"
        tools:ignore="ContentDescription"
        />
</RelativeLayout>

我正在尝试为类似于Facebook Messenger应用程序中使用的著名气泡创建动画。

任何对其进行动画处理的选项都会导致其消失,就像动画没有像移动中心一样作用于整个对象,但就像应用于视图的边缘和尺寸一样。

将路径定义为线性或弯曲等其他选项也会产生相同的结果。

找到的选项here too也不起作用。

我基本上知道,这些动画是用于视图转换的,因此将大多数动画应用于边缘(左,右,上,下)是合乎逻辑的。

我尝试了类似的选项

ObjectAnimator.ofFloat(view,"translationX",100f);

path = new Path();
path.arcTo(0f,0f,1000f,270f,-180f,true);
objectAnimator = ObjectAnimator.ofFloat(headView,View.X,View.Y,path);
objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
objectAnimator.setRepeatCount(5);
objectAnimator.setDuration(10000);

,并使用View.X,View.Y个属性进行播放,例如: "x","y"

ObjectAnimator.ofFloat(headView,ImageView.SCALE_X,0.2f,1f);

一切似乎都很相似。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)