@Override public void transform(float dragProgress, View rootView) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { float elevation = SideNavUtils.evaluate(dragProgress, START_ELEVATION, endElevation); rootView.setElevation(elevation); } } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void setElevation(float elevation) { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) super.setElevation(elevation); else if(mBackground.setShadow(elevation, elevation)) requestLayout(); }
@Override public void setElevation(float elevation) { if (Carbon.IS_PIE_OR_HIGHER) { super.setElevation(elevation); super.setTranslationZ(translationZ); } else if (Carbon.IS_LOLLIPOP_OR_HIGHER) { if ((ambientShadowColor == null || spotShadowColor == null) && renderingMode == RenderingMode.Auto) { super.setElevation(elevation); super.setTranslationZ(translationZ); } else { super.setElevation(0); super.setTranslationZ(0); } } else if (elevation != this.elevation && getParent() != null) { ((android.view.View) getParent()).postInvalidate(); } this.elevation = elevation; }
@SuppressWarnings("deprecation") public CircleImageView(Context context, int color) { super(context); final View thisView = this; final float density = thisView.getResources().getDisplayMetrics().density; final int shadowYOffset = (int) (density * Y_OFFSET); final int shadowXOffset = (int) (density * X_OFFSET); mShadowRadius = (int) (density * SHADOW_RADIUS); ShapeDrawable circle; if (android.os.Build.VERSION.SDK_INT >= 21) { circle = new ShapeDrawable(new OvalShape()); thisView.setElevation(SHADOW_ELEVATION * density); } else { OvalShape oval = new OvalShadow(mShadowRadius); circle = new ShapeDrawable(oval); thisView.setLayerType(LAYER_TYPE_SOFTWARE, circle.getPaint()); circle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset, KEY_SHADOW_COLOR); final int padding = mShadowRadius; // set padding so the inner image sits correctly within the shadow. thisView.setPadding(padding, padding, padding, padding); } circle.getPaint().setColor(color); if (Build.VERSION.SDK_INT >= 16) { thisView.setBackground(circle); } else { thisView.setBackgroundDrawable(circle); } }
@Test @Config(minSdk = LOLLIPOP) public void elevation() { view.setElevation(10f); assertThat(view.getElevation()).isEqualTo(10f); }
this.mView.setBackground(BackgroundUtils.getBackground(this.mStyle, this.mStyle.color)); if (sdkVersion >= Build.VERSION_CODES.LOLLIPOP) mView.setElevation(3f); } else this.mView.setBackgroundDrawable(BackgroundUtils.getBackground(this.mStyle, this.mStyle.color));
drawer.mStickyHeaderView.setElevation(UIUtils.convertDpToPixel(4, drawer.mActivity)); } else { View view = new View(drawer.mActivity);
v.setElevation(a.getDimensionPixelOffset(attr, 0));
@Override public void onAnimationUpdate(ValueAnimator animation) { view.setElevation((float)animation.getAnimatedValue());
@Override public void setDimension(V view, float dimension) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { view.setElevation(dimension); } } });
@Override public void onClick(View v) { mElevation -= mElevationStep; // Don't allow for negative values of Z. if (mElevation < 0) { mElevation = 0; } Log.d(TAG, String.format(Locale.US, "Elevation: %.1f", mElevation)); floatingShape.setElevation(mElevation); } });
public void setShadow(View v, boolean on) { if (android.os.Build.VERSION.SDK_INT >= 21) { v.setElevation(on ? dp2px(8) : 0); } }
@Override public void setElevation(ToggleGroupDelegate groupView, float elevation) { groupView.getToggleGroup().setElevation(elevation); }
@Override public void onViewCaptured(@NonNull View capturedChild, int activePointerId) { capturedChild.setElevation(getElevation() + 1); capturedLeft = capturedChild.getLeft(); capturedTop = capturedChild.getTop(); }
@Override public void onClick(View v) { mElevation += mElevationStep; Log.d(TAG, String.format(Locale.US, "Elevation: %.1f", mElevation)); floatingShape.setElevation(mElevation); } });
@Override public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { liparam.view.setElevation(0); liparam.view.setPadding(0, 0, 0, 0); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) liparam.view.getLayoutParams(); params.height = ResourceUtils.getInstance(liparam.view.getContext()).getDimensionPixelSize(R.dimen.status_bar_header_height); } });
@Override public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable { liparam.view.setElevation(0); liparam.view.setPadding(0, 0, 0, 0); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) liparam.view.getLayoutParams(); params.height = ResourceUtils.getInstance(liparam.view.getContext()).getDimensionPixelSize(R.dimen.status_bar_header_height); } });
@Override public void onViewDragStateChanged(int state) { if (state == ViewDragHelper.STATE_IDLE) { View capturedView = dragHelper.getCapturedView(); if (capturedView != null) { capturedView.setElevation(capturedView.getElevation() - 1); } } }
@Override public void initialize(CardViewDelegate cardView, Context context, int backgroundColor, float radius) { cardView.setBackgroundDrawable(new RoundRectDrawable(backgroundColor, radius)); View view = (View) cardView; view.setClipToOutline(true); view.setElevation(context.getResources().getDimension(R.dimen.cardview_elevation)); }
@Override public void initialize(CardViewDelegate cardView, Context context, int backgroundColor, float radius) { cardView.setBackgroundDrawable(new RoundRectDrawable(backgroundColor, radius)); View view = (View) cardView; view.setClipToOutline(true); view.setElevation(context.getResources().getDimension(R.dimen.cardview_elevation)); }