当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.getElevation方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewCompat.getElevation方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.getElevation方法的具体用法?Java ViewCompat.getElevation怎么用?Java ViewCompat.getElevation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.getElevation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateSnackbar

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void updateSnackbar(CoordinatorLayout parent, View dependency, View child) {
    if (dependency instanceof Snackbar.SnackbarLayout) {
        if (mSnackbarHeight == -1) {
            mSnackbarHeight = dependency.getHeight();
        }

        int targetPadding = child.getMeasuredHeight();

        int shadow = (int) ViewCompat.getElevation(child);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dependency.getLayoutParams();
        layoutParams.bottomMargin = targetPadding - shadow;
        child.bringToFront();
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            child.getParent().requestLayout();
            ((View) child.getParent()).invalidate();
        }

    }
}
 
开发者ID:homeii,项目名称:GxIconDIY,代码行数:21,代码来源:BottomNavigationBehavior.java

示例2: ContentViewHolder

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * @param view         The {@link View} being hosted in this ViewHolder
 * @param adapter      Adapter instance of type {@link FlexibleAdapter}
 * @param stickyHeader true if the ViewHolder is a header to be sticky
 * @since 5.0.0-b7
 */
ContentViewHolder(View view, FlexibleAdapter adapter, boolean stickyHeader) {
	// Since itemView is declared "final", the split is done before the View is initialized
	super(stickyHeader ? new FrameLayout(view.getContext()) : view);

	if (stickyHeader) {
		itemView.setLayoutParams(adapter.getRecyclerView().getLayoutManager()
				.generateLayoutParams(view.getLayoutParams()));
		((FrameLayout) itemView).addView(view); //Add View after setLayoutParams
		float elevation = ViewCompat.getElevation(view);
		if (elevation > 0) {
			ViewCompat.setBackground(itemView, view.getBackground());
			ViewCompat.setElevation(itemView, elevation);
		}
		contentView = view;
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:ContentViewHolder.java

示例3: configureLayoutElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void configureLayoutElevation() {
	// 1. Take elevation from header item layout (most important)
	mElevation = ViewCompat.getElevation(mStickyHeaderViewHolder.getContentView());
	if (mElevation == 0f) {
		// 2. Take elevation settings
		mElevation = mAdapter.getStickyHeaderElevation();
	}
	if (mElevation > 0) {
		// Needed to elevate the view
		ViewCompat.setBackground(mStickyHolderLayout, mStickyHeaderViewHolder.getContentView().getBackground());
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:StickyHeaderHelper.java

示例4: onDraw

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas c, RecyclerView recyclerView, View view,
        float dX, float dY, int actionState, boolean isCurrentlyActive) {
    if (isCurrentlyActive) {
        Object originalElevation = view.getTag();
        if (originalElevation == null) {
            originalElevation = ViewCompat.getElevation(view);
            float newElevation = 1f + findMaxElevation(recyclerView, view);
            ViewCompat.setElevation(view, newElevation);
            view.setTag(originalElevation);
        }
    }
    super.onDraw(c, recyclerView, view, dX, dY, actionState, isCurrentlyActive);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:15,代码来源:ItemTouchUIUtilImpl.java

示例5: findMaxElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private float findMaxElevation(RecyclerView recyclerView, View itemView) {
    final int childCount = recyclerView.getChildCount();
    float max = 0;
    for (int i = 0; i < childCount; i++) {
        final View child = recyclerView.getChildAt(i);
        if (child == itemView) {
            continue;
        }
        final float elevation = ViewCompat.getElevation(child);
        if (elevation > max) {
            max = elevation;
        }
    }
    return max;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:16,代码来源:ItemTouchUIUtilImpl.java

示例6: findMaxElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private float findMaxElevation(RecyclerView recyclerView, View itemView) {
    int childCount = recyclerView.getChildCount();
    float max = 0.0f;
    for (int i = 0; i < childCount; i++) {
        View child = recyclerView.getChildAt(i);
        if (child != itemView) {
            float elevation = ViewCompat.getElevation(child);
            if (elevation > max) {
                max = elevation;
            }
        }
    }
    return max;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:15,代码来源:ItemTouchUIUtilImpl.java

示例7: onDraw

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    //  super.onDraw(canvas);

    paint.setStyle(Paint.Style.FILL);
    switch (config.getType()) {
        case 0:
            paint.setColor(config.getBaseColor());
            break;
        case 1:
            paint.setShader(config.getLinearGradient(config.getAngle(), width, height));
            break;
        case 2:
            paint.setShader(config.getRadialGradient(width, height));
            break;
        case 3:
            setupBitmap(this, width, height);
            break;
    }
        paint.setStrokeJoin(Paint.Join.ROUND);    // set the join to round you want
        paint.setStrokeCap(Paint.Cap.ROUND);      // set the paint cap to round too
        paint.setPathEffect(new CornerPathEffect(config.getRadius()));
    ViewCompat.setElevation(this, config.getShadow());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && ViewCompat.getElevation(this) > 0f) {

        try {
            setOutlineProvider(getOutlineProvider());
        } catch (Exception e) {
            Log.e("Exception", e.getMessage());
            e.printStackTrace();
        }
    }
    paint.setXfermode(pdMode);
    canvas.drawPath(path, paint);
}
 
开发者ID:akshay2211,项目名称:Oblique,代码行数:36,代码来源:ObliqueView.java

示例8: onMeasure

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    int heightSize = MeasureSpec.getSize(heightMeasureSpec);
    if (!(widthMode == 1073741824 && heightMode == 1073741824)) {
        if (isInEditMode()) {
            if (widthMode != Integer.MIN_VALUE) {
                if (widthMode == 0) {
                    widthSize = 300;
                }
            }
            if (heightMode != Integer.MIN_VALUE) {
                if (heightMode == 0) {
                    heightSize = 300;
                }
            }
        } else {
            throw new IllegalArgumentException("DrawerLayout must be measured with MeasureSpec.EXACTLY.");
        }
    }
    setMeasuredDimension(widthSize, heightSize);
    boolean applyInsets = this.mLastInsets != null && ViewCompat.getFitsSystemWindows(this);
    int layoutDirection = ViewCompat.getLayoutDirection(this);
    boolean hasDrawerOnLeftEdge = false;
    boolean hasDrawerOnRightEdge = false;
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        if (child.getVisibility() != 8) {
            MarginLayoutParams lp = (LayoutParams) child.getLayoutParams();
            if (applyInsets) {
                int cgrav = GravityCompat.getAbsoluteGravity(lp.gravity, layoutDirection);
                if (ViewCompat.getFitsSystemWindows(child)) {
                    IMPL.dispatchChildInsets(child, this.mLastInsets, cgrav);
                } else {
                    IMPL.applyMarginInsets(lp, this.mLastInsets, cgrav);
                }
            }
            if (isContentView(child)) {
                child.measure(MeasureSpec.makeMeasureSpec((widthSize - lp.leftMargin) - lp.rightMargin, 1073741824), MeasureSpec.makeMeasureSpec((heightSize - lp.topMargin) - lp.bottomMargin, 1073741824));
            } else if (isDrawerView(child)) {
                if (SET_DRAWER_SHADOW_FROM_ELEVATION && ViewCompat.getElevation(child) != this.mDrawerElevation) {
                    ViewCompat.setElevation(child, this.mDrawerElevation);
                }
                int childGravity = getDrawerViewAbsoluteGravity(child) & 7;
                boolean isLeftEdgeDrawer = childGravity == 3;
                if (!(isLeftEdgeDrawer && hasDrawerOnLeftEdge) && (isLeftEdgeDrawer || !hasDrawerOnRightEdge)) {
                    if (isLeftEdgeDrawer) {
                        hasDrawerOnLeftEdge = true;
                    } else {
                        hasDrawerOnRightEdge = true;
                    }
                    child.measure(getChildMeasureSpec(widthMeasureSpec, (this.mMinDrawerMargin + lp.leftMargin) + lp.rightMargin, lp.width), getChildMeasureSpec(heightMeasureSpec, lp.topMargin + lp.bottomMargin, lp.height));
                } else {
                    throw new IllegalStateException("Child drawer has absolute gravity " + gravityToString(childGravity) + " but this " + TAG + " already has a " + "drawer view along that edge");
                }
            } else {
                throw new IllegalStateException("Child " + child + " at index " + i + " does not have a valid layout_gravity - must be Gravity.LEFT, " + "Gravity.RIGHT or Gravity.NO_GRAVITY");
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:64,代码来源:DrawerLayout.java

示例9: getElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public float getElevation() {
    return ViewCompat.getElevation(this.mDecorToolbar.getViewGroup());
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:ToolbarActionBar.java

示例10: getElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public float getElevation() {
    return ViewCompat.getElevation(this.mContainerView);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:WindowDecorActionBar.java


注:本文中的android.support.v4.view.ViewCompat.getElevation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。