Android 如何在LayoutParams上应用动画

Android 如何在LayoutParams上应用动画,android,android-animation,android-relativelayout,Android,Android Animation,Android Relativelayout,我想知道是否有办法在LayoutParams上应用动画。故事是这样的。 假设我有以下布局,一个TextView位于RelativeLayout的左上角 <RelativeLayout ...> <TextView android:alignParentStart="true" android:alignParentTop="true"/> ... <RelativeLayout /> 只是想知道是否有一种方法可

我想知道是否有办法在
LayoutParams
上应用动画。故事是这样的。 假设我有以下布局,一个
TextView
位于
RelativeLayout
的左上角

<RelativeLayout ...>
    <TextView
        android:alignParentStart="true"
        android:alignParentTop="true"/>
    ...
<RelativeLayout />

只是想知道是否有一种方法可以使用
Animator
?谢谢。

您可以做的一件事是使用
android:centerInParent=“true”
TexView
始终放在他父母的中心,并使用
ValueAnimator
ObjectAnimator
为他父母的
宽度和
高度设置动画。

显然,如果你能以某种方式计算屏幕的宽度会更好,但我想这足以扩展布局父类(
RelativeLayout
),并覆盖他的
onMeasure
onLayout
方法。

试着将其插入到你的
RelativeLayout
安卓:animateLayoutChanges=“true”
<RelativeLayout ...>
    <TextView
        android:centerInParent="true"/>
    ...
<RelativeLayout />