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 />