Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a solution for this.</p> <p>If you dont need to support lower API levels and are fine with API level 11 onwards, you can use ObjectAnimator for this. ObjectAnimator has a translatey method which works quite well.</p> <p>If you need to support API 8 onwards, you need to make sure your view comes within the bounds of the screen and then animates. The following code modification did the trick.</p> <p>I know it seems very weird, do let me know if there is a better way to do this.</p> <pre><code> public void smoothExpanderAnimate(boolean addSpecialFix,final int finalTarget,final RelativeLayout expander,final int animateToY,final boolean setExpanded,final boolean refreshGrid) { final RelativeLayout.LayoutParams head_params = (RelativeLayout.LayoutParams)expander.getLayoutParams(); TranslateAnimation anim = new TranslateAnimation(0f, 0f, 0f, animateToY); anim.setDuration(400); expander.setVisibility(View.INVISIBLE); //Make View invisible if(isExpanded &amp;&amp; addSpecialFix){ //THIS IS THE FIX int old = head_params.topMargin; head_params.topMargin = finalTarget; expander.clearAnimation(); expander.setLayoutParams(head_params); //move invisible view to the final position anim = new TranslateAnimation(0f, 0f, old-closedY, 0); Log.d("asdasd", old+""); anim.setDuration(400); } //timeListHeight = list.getHeight(); //anim.setFillAfter(true); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { head_params.topMargin = finalTarget; expander.clearAnimation(); expander.setLayoutParams(head_params); isExpanded = setExpanded; isAnimating = false; expander.setVisibility(View.VISIBLE); if(refreshGrid) { mCalAdapter.notifyDataSetChanged(); } if(!setExpanded) { setListHeight(timeListHeight, list); } } }); isAnimating = true; expander.startAnimation(anim); } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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