Note that there are some explanatory texts on larger screens.

plurals
  1. POsetting layout params after animation
    primarykey
    data
    text
    <p>i have 2 views in a <code>RelativeLayout</code> like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;View android:id="@+id/view1" android:layout_width="match_parent" android:layout_height="200dp" android:background="@drawable/shape_red"/&gt; &lt;View android:id="@+id/view2" android:layout_width="match_parent" android:layout_height="50dp" android:layout_below="@id/view1" android:background="@drawable/shape_blue"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>now, i animate the y property of <code>view1</code> from 0 to 300. but i want <code>view2</code> to change its position according to <code>view1</code> - because <code>view2</code> is set to be below (layout-below) <code>view1</code>.</p> <p>as this isn't working, i tried to add an <code>onAnimationEnd</code> listener to the animation. like this:</p> <pre><code> ObjectAnimator ani = ObjectAnimator.ofFloat(view1, "Y", 200); ani.setDuration(2000); ani.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, view2.getHeight()); params.addRule(RelativeLayout.BELOW, view1.getId()); view2.setLayoutParams(params); } }); </code></pre> <p>but <code>view2</code> didn't change its position at all.</p> <p>i would like to avoid making a new animation for <code>view2</code> if possible, so please don't bother to suggest one. ;)</p> <p>does anyone have some suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload