I have a linearlayout that contains 4 nested linear layouts. I need to hide the first nested layout and show the 2 and 3 and then hide the 2 and 3 and show the 1st. I would like to animate these transistions with sliding effects. So have the 1st slide of the screen and then the 2 and 3 slide on. I have managed to animate 1 sliding off ( although not very smoothly ) but can't figure out how to do the slide on to go from View.GONE to View.VISIBLE.
Without the animation is I just do setVisiblity on the 1st to hide it and then setVisiblity on the 2/3 to shot them then it is very glitchy and the text overlaps.
See below for the problem I am encountering.
The code that I am using to hide / show currently:
LinearLayout item2= (LinearLayout) rootView.findViewById(R.id.item2);
LinearLayout item1= (LinearLayout) rootView.findViewById(R.id.item2);
item1.setVisibility(View.GONE);
item2.setVisibility(View.VISIBLE);
A View's visibility status is of Integer type and can have one of three options: VISIBLE (0) - The View is visible to the user. INVISIBLE (4) - The View is invisible to the user, but still takes up space in the layout. GONE (8) - The View is invisible, and it does not take up space in the layout.
Use alpha animation on the view which you want to make invisible. Also use AnimationUpdateListener and once the animation is completed make the view invisible.
You can let Android animate layout changes for you. Every time you change something in the layout like changing view visibility or view positions android will automatically create fade / transition animations. To use that set this on the root node in your layout;
android:animateLayoutChanges="true"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With