Search code examples
androidsliding

Sliding animation while adding showing layout


I want to show/hide a layout but with adding a sliding effect while it's appearing and hiding but i'm bound to min SDK 8 to cover as much devices as possible , how can i achieve that ?


Solution

  • You can use animations like slide out, slide in in combination with alpha. A simple example If I am correct about getting your question could be Gallery's header and footer animation. Clicking on the image shows the header and footer with sliding effect and showing and hiding the views.

    Slide animation out bottom

        <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:fillAfter="true"
        android:fillEnabled="true"
        android:interpolator="@android:anim/accelerate_decelerate_interpolator" >
    
        <!-- Slide in is basically view coming in from some outside area, in this case bottom -->
        <translate
            android:duration="500"
            android:fromYDelta="100%"
            android:toYDelta="0%" />
    
    </set>
    

    You can change the value and achieve the slide animation. If required I can assist you in getting the other slide animation or you can google it.