private void animateLastRequests(int from, int to) { suggestionsVisible = to > 0 ? true : false; final RelativeLayout last = (RelativeLayout) findViewById(R.id.last); final ViewGroup.LayoutParams lp = last.getLayoutParams(); ValueAnimator animator = ValueAnimator.ofInt(from, to); animator.setDuration(200); animator.addUpdateListener( new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { lp.height = (int) animation.getAnimatedValue(); last.setLayoutParams(lp); } }); if (adapter.getItemCount() > 0) animator.start(); }
private int getListHeight() { return (int) ((adapter.getItemCount() * 50) * destiny); }