public void showNext() { if (height <= 0) { height = topToast1.getHeight(); } ObjectAnimator anim1 = ObjectAnimator.ofFloat(topToastArray[(showPosition + 1) % length], "y", -height, 0f); ObjectAnimator anim2 = ObjectAnimator.ofFloat(topToastArray[showPosition], "y", 0f, height); AnimatorSet animSet = new AnimatorSet(); animSet.play(anim1).with(anim2); animSet.setDuration(500); animSet.start(); showPosition = (showPosition + 1) % length; }
private void init() { this.setOrientation(VERTICAL); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); this.setLayoutParams(params); LinearLayout.LayoutParams params1 = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, (int) context .getResources() .getDimension(R.dimen.abc_action_bar_default_height_material)); this.addView(topToastArray[0], params1); this.addView(topToastArray[1], params1); this.addView(topToastArray[2], params1); this.addView(topToastArray[3], params1); length = topToastArray.length; Log.d("TAG", "first:" + topToast1.getHeight()); }