本文整理汇总了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();
}
}
}
示例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;
}
}
示例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());
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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");
}
}
}
}
示例9: getElevation
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public float getElevation() {
return ViewCompat.getElevation(this.mDecorToolbar.getViewGroup());
}
示例10: getElevation
import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public float getElevation() {
return ViewCompat.getElevation(this.mContainerView);
}