I know that it is very late to answer this question, but Iโll just tell you how I chose the animation of layout changes for those in need.
Android has a special Animation class called ScaleAnimation where we can smoothly expand or collapse views.
Show view by expanding diagonally:
ScaleAnimation expand = new ScaleAnimation( 0, 1.0f, 0, 1.0f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); expand.setDuration(250); view.startAnimation(expand)
where the constructor is used:
ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
This way you can change the values โโaccordingly.
For example, the following example will animate the horizontal view:
ScaleAnimation expand = new ScaleAnimation( 0, 1.1f, 1f, 1f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); expand.setDuration(250);
You can change from fromX , to toX , from fromY toY to toY .
For example, if a view is displayed and you just need to expand it, place from fromX and fromY to 1.0f and toX toY as appropriate.
Now, using the same class, you can create a cooler effect to display the view by expanding the view a bit and then reducing it to its original size. An AnimationSet will be used for this. So this would create a kind of bubble effect.
The following is an example of creating a bubble effect to display a view:
AnimationSet expandAndShrink = new AnimationSet(true); ScaleAnimation expand = new ScaleAnimation( 0, 1.1f, 0, 1.1f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); expand.setDuration(250); ScaleAnimation shrink = new ScaleAnimation( 1.1f, 1f, 1.1f, 1f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); shrink.setStartOffset(250); shrink.setDuration(120); expandAndShrink.addAnimation(expand); expandAndShrink.addAnimation(shrink); expandAndShrink.setFillAfter(true); expandAndShrink.setInterpolator(new AccelerateInterpolator(1.0f)); view.startAnimation(expandAndShrink);