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


Java View.setElevation方法代码示例

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


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

示例1: addArrowView

import android.view.View; //导入方法依赖的package包/类
/**
 * Adds an arrow view pointing at the original icon.
 * @param horizontalOffset the horizontal offset of the arrow, so that it
 *                              points at the center of the original icon
 */
private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) {
    LinearLayout.LayoutParams layoutParams = new LayoutParams(width, height);
    if (mIsLeftAligned) {
        layoutParams.gravity = Gravity.LEFT;
        layoutParams.leftMargin = horizontalOffset;
    } else {
        layoutParams.gravity = Gravity.RIGHT;
        layoutParams.rightMargin = horizontalOffset;
    }
    if (mIsAboveIcon) {
        layoutParams.topMargin = verticalOffset;
    } else {
        layoutParams.bottomMargin = verticalOffset;
    }

    View arrowView = new View(getContext());
    ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
            width, height, !mIsAboveIcon));
    arrowDrawable.getPaint().setColor(Color.WHITE);
    arrowView.setBackground(arrowDrawable);
    arrowView.setElevation(getElevation());
    addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams);
    return arrowView;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:30,代码来源:DeepShortcutsContainer.java

示例2: setAppbarEvent

import android.view.View; //导入方法依赖的package包/类
private void setAppbarEvent() {
    AppBarLayout appBar = (AppBarLayout) getParent();

    if (appBar.getParent().getClass().equals(CoordinatorLayout.class)) {
        CoordinatorLayout rootLayout = (CoordinatorLayout) appBar.getParent();

        View tabs = getChildAt(0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            tabs.setElevation(getResources().getDimensionPixelOffset(R.dimen.tabs_elevation));
        }

        removeView(tabs);
        rootLayout.addView(tabs);

        getLayoutParams().height = getResources().getDimensionPixelOffset(R.dimen.fancy_tab_layout_height);
        requestLayout();
        isFloating = true;
    }

    appBar.addOnOffsetChangedListener(onOffsetChangedListener);
}
 
开发者ID:ypicoleal,项目名称:FancyTab,代码行数:22,代码来源:FancyTabLayout.java

示例3: initialize

import android.view.View; //导入方法依赖的package包/类
@Override
public void initialize(CardViewDelegate cardView, Context context, int backgroundColor,
        float radius, float elevation, float maxElevation) {
    final RoundRectDrawable backgroundDrawable = new RoundRectDrawable(backgroundColor, radius);
    cardView.setBackgroundDrawable(backgroundDrawable);
    View view = (View) cardView;
    view.setClipToOutline(true);
    view.setElevation(elevation);
    setMaxElevation(cardView, maxElevation);
}
 
开发者ID:stytooldex,项目名称:pius1,代码行数:11,代码来源:CardViewApi21.java

示例4: addArrowView

import android.view.View; //导入方法依赖的package包/类
/**
 * Adds an arrow view pointing at the original icon.
 * @param horizontalOffset the horizontal offset of the arrow, so that it
 *                              points at the center of the original icon
 */
private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) {
    LayoutParams layoutParams = new LayoutParams(width, height);
    if (mIsLeftAligned) {
        layoutParams.gravity = Gravity.START;
        layoutParams.leftMargin = horizontalOffset;
    } else {
        layoutParams.gravity = Gravity.END;
        layoutParams.rightMargin = horizontalOffset;
    }
    if (mIsAboveIcon) {
        layoutParams.topMargin = verticalOffset;
    } else {
        layoutParams.bottomMargin = verticalOffset;
    }

    View arrowView = new View(getContext());
    if (Gravity.isVertical(((FrameLayout.LayoutParams) getLayoutParams()).gravity)) {
        // This is only true if there wasn't room for the container next to the icon,
        // so we centered it instead. In that case we don't want to show the arrow.
        arrowView.setVisibility(INVISIBLE);
    } else {
        ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create(
                width, height, !mIsAboveIcon));
        Paint arrowPaint = arrowDrawable.getPaint();
        // Note that we have to use getChildAt() instead of getItemViewAt(),
        // since the latter expects the arrow which hasn't been added yet.
        PopupItemView itemAttachedToArrow = (PopupItemView)
                (getChildAt(mIsAboveIcon ? getChildCount() - 1 : 0));
        arrowPaint.setColor(itemAttachedToArrow.getArrowColor(mIsAboveIcon));
        // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable.
        int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius);
        arrowPaint.setPathEffect(new CornerPathEffect(radius));
        arrowView.setBackground(arrowDrawable);
        arrowView.setElevation(getElevation());
    }
    addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams);
    return arrowView;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:44,代码来源:PopupContainerWithArrow.java

示例5: elevationBoolean

import android.view.View; //导入方法依赖的package包/类
@BindingAdapter("elevation")
public static void elevationBoolean(View view, boolean elevation) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && elevation) {
        view.setElevation(view.getContext().getResources().getInteger(R.integer.common_elevation));
    } else {
        jLogger.w("Sorry, the system version of the device is under API 21, elevation will take no effect.");
    }
}
 
开发者ID:Mindjet,项目名称:LiteReader,代码行数:9,代码来源:BaseBindingAdapter.java

示例6: setElevation

import android.view.View; //导入方法依赖的package包/类
/**
 * Set elevation if supported.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static boolean setElevation(View view, float elevationValue) {
    if (!isElevationSupported()) return false;

    view.setElevation(elevationValue);
    return true;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:11,代码来源:ApiCompatibilityUtils.java

示例7: transform

import android.view.View; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:yarolegovich,项目名称:SlidingRootNav,代码行数:8,代码来源:ElevationTransformation.java

示例8: SaturationValuePicker

import android.view.View; //导入方法依赖的package包/类
public SaturationValuePicker(Context context, AttributeSet attrs) {
    super(context, attrs);
    mColor = new Color();

    setClipChildren(false);
    setClipToPadding(false);

    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    mDensity = metrics.density;

    mSelectorRadius = SELECTOR_RADIUS_DP * mDensity;

    View v = new View(context);
    v.setLayoutParams(new LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
    ));

    // We want the selector to protrude as minimally as possible from the selection drawable and
    // we want to inset the gradients in the drawable so that the color under the selector's
    // midpoint always reflects the current color (thus the limits of the saturation-value
    // gradients have to be clamped at this inset. The inset value is thus the shorter side of
    // a 45 degree triangle (1 / root 2) with hypotnus equal to the radius of the selector.
    mInset = mSelectorRadius / (float) Math.sqrt(2);
    mSVDrawable = new SaturationValueDrawable(mInset);
    v.setBackground(mSVDrawable);
    addView(v);

    mSelectorParams = new LayoutParams(
            Math.round(mSelectorRadius * 2), Math.round(mSelectorRadius * 2)
    );
    mSelector = new View(context);
    mSelector.setLayoutParams(mSelectorParams);
    mSelectorDrawable = (GradientDrawable) ContextCompat.getDrawable(
            context, R.drawable.drawable_selector);
    mSelector.setBackground(mSelectorDrawable);
    mSelector.setElevation(SELECTOR_ELEVATION_DP * mDensity);
    addView(mSelector);
}
 
开发者ID:google,项目名称:spline,代码行数:39,代码来源:SaturationValuePicker.java

示例9: initialize

import android.view.View; //导入方法依赖的package包/类
public void initialize(CardViewDelegate cardView, Context context, int backgroundColor, float radius, float elevation, float maxElevation) {
    cardView.setBackgroundDrawable(new RoundRectDrawable(backgroundColor, radius));
    View view = (View) cardView;
    view.setClipToOutline(true);
    view.setElevation(elevation);
    setMaxElevation(cardView, maxElevation);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:CardViewApi21.java

示例10: toStartState

import android.view.View; //导入方法依赖的package包/类
@Override
protected void toStartState(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setElevation(fromElevation);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:WoWoElevationAnimation.java

示例11: set

import android.view.View; //导入方法依赖的package包/类
@Override
public void set(View object, Float value) {
    object.setElevation(value);
}
 
开发者ID:wirecube,项目名称:android_additive_animations,代码行数:5,代码来源:ElevationProperties.java

示例12: toEndState

import android.view.View; //导入方法依赖的package包/类
@Override
protected void toEndState(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setElevation(toElevation);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:WoWoElevationAnimation.java

示例13: toMiddleState

import android.view.View; //导入方法依赖的package包/类
@Override
protected void toMiddleState(View view, float offset) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setElevation(fromElevation + (toElevation - fromElevation) * offset);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:CustomAnimation.java

示例14: ViewHolder

import android.view.View; //导入方法依赖的package包/类
public ViewHolder(@NonNull View itemView, int itemViewType) {
    super(itemView);

    if (itemViewType == SMART_PLAYLIST) {
        if (shortSeparator != null) {
            shortSeparator.setVisibility(View.GONE);
        }
        itemView.setBackgroundColor(ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            itemView.setElevation(activity.getResources().getDimensionPixelSize(R.dimen.card_elevation));
        }
    }

    if (image != null) {
        int iconPadding = activity.getResources().getDimensionPixelSize(R.dimen.list_item_image_icon_padding);
        image.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
        image.setColorFilter(ATHUtil.resolveColor(activity, R.attr.iconColor), PorterDuff.Mode.SRC_IN);
    }

    if (menu != null) {
        menu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final Playlist playlist = dataSet.get(getAdapterPosition());
                final PopupMenu popupMenu = new PopupMenu(activity, view);
                popupMenu.inflate(getItemViewType() == SMART_PLAYLIST ? R.menu.menu_item_smart_playlist : R.menu.menu_item_playlist);
                if (playlist instanceof LastAddedPlaylist) {
                    popupMenu.getMenu().findItem(R.id.action_clear_playlist).setVisible(false);
                }
                popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    @Override
                    public boolean onMenuItemClick(@NonNull MenuItem item) {
                        if (item.getItemId() == R.id.action_clear_playlist) {
                            if (playlist instanceof AbsSmartPlaylist) {
                                ClearSmartPlaylistDialog.create((AbsSmartPlaylist) playlist).show(activity.getSupportFragmentManager(), "CLEAR_SMART_PLAYLIST_" + playlist.name);
                                return true;
                            }
                        }
                        return PlaylistMenuHelper.handleMenuClick(
                                activity, dataSet.get(getAdapterPosition()), item);
                    }
                });
                popupMenu.show();
            }
        });
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:48,代码来源:PlaylistAdapter.java

示例15: ViewHolder

import android.view.View; //导入方法依赖的package包/类
public ViewHolder(@NonNull View itemView, int itemViewType) {
    super(itemView);
    itemView.setOnLongClickListener(null);

    if (itemViewType != HEADER) {
        itemView.setBackgroundColor(ATHUtil.resolveColor(activity, R.attr.cardBackgroundColor));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            itemView.setElevation(activity.getResources().getDimensionPixelSize(R.dimen.card_elevation));
        }
        if (shortSeparator != null) {
            shortSeparator.setVisibility(View.GONE);
        }
    }

    if (menu != null) {
        if (itemViewType == SONG) {
            menu.setVisibility(View.VISIBLE);
            menu.setOnClickListener(new SongMenuHelper.OnClickSongMenu(activity) {
                @Override
                public Song getSong() {
                    return (Song) dataSet.get(getAdapterPosition());
                }
            });
        } else {
            menu.setVisibility(View.GONE);
        }
    }

    switch (itemViewType) {
        case ALBUM:
            setImageTransitionName(activity.getString(R.string.transition_album_art));
            break;
        case ARTIST:
            setImageTransitionName(activity.getString(R.string.transition_artist_image));
            break;
        default:
            View container = itemView.findViewById(R.id.image_container);
            if (container != null) {
                container.setVisibility(View.GONE);
            }
            break;
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:44,代码来源:SearchAdapter.java


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