本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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.");
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例11: set
import android.view.View; //导入方法依赖的package包/类
@Override
public void set(View object, Float value) {
object.setElevation(value);
}
示例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);
}
}
示例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);
}
}
示例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();
}
});
}
}
示例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;
}
}