toggle Content Visibility - Android android.view

Android examples for android.view:View

Description

toggle Content Visibility

Demo Code

import android.view.View;

public class Main{

    public static void toggleContentVisibility(View... views) {
        for (final View v : views) {
            if (v.getVisibility() == View.GONE) {
                v.setAlpha(0);//  ww  w . j a  v a2 s . c o  m
                v.setVisibility(View.VISIBLE);
                v.animate().alpha(1).start();
            } else {
                v.animate().alpha(0).setDuration(100)
                        .withEndAction(new Runnable() {
                            @Override
                            public void run() {
                                v.setVisibility(View.GONE);
                            }
                        }).start();
            }
        }
    }

}

Related Tutorials