Example usage for android.view ViewGroup setElevation

List of usage examples for android.view ViewGroup setElevation

Introduction

In this page you can find the example usage for android.view ViewGroup setElevation.

Prototype

public void setElevation(float elevation) 

Source Link

Document

Sets the base elevation of this view, in pixels.

Usage

From source file:info.papdt.blacklight.ui.common.AbsActivity.java

@TargetApi(21)
private void swipeInit() {
    // Replace the view first
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    SlidingPaneLayout v = (SlidingPaneLayout) inflater.inflate(R.layout.swipe_decor_wrapper, null);
    final ViewGroup frame = (ViewGroup) v.findViewById(R.id.swipe_container);
    View swipeView = getSwipeView();
    ViewGroup decor = (ViewGroup) swipeView.getParent();
    ViewGroup.LayoutParams params = swipeView.getLayoutParams();
    decor.removeView(swipeView);/* ww  w  .j  av  a  2 s.c  om*/
    frame.addView(swipeView);
    decor.addView(v, params);
    decor.setBackgroundColor(0);

    // Elevation
    if (Build.VERSION.SDK_INT >= 21) {
        frame.setElevation(11.8f);
    } else {
        v.setShadowResource(R.drawable.panel_shadow);
    }

    // Swipe gesture configurations
    v.setSliderFadeColor(0);
    v.setPanelSlideListener(new SlidingPaneLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View v, float percent) {
            getWindow().getDecorView().setAlpha(1.0f - percent);
        }

        @Override
        public void onPanelOpened(View p1) {
            finish();
        }

        @Override
        public void onPanelClosed(View p1) {
        }
    });

    // Adjust window color
    getWindow().setBackgroundDrawable(new ColorDrawable(0));
}