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


Java ViewCompat.setElevation方法代码示例

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


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

示例1: AppBarLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public AppBarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.mTotalScrollRange = -1;
    this.mDownPreScrollRange = -1;
    this.mDownScrollRange = -1;
    this.mPendingAction = 0;
    setOrientation(1);
    ThemeUtils.checkAppCompatTheme(context);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, 0, R.style.Widget_Design_AppBarLayout);
    this.mTargetElevation = (float) a.getDimensionPixelSize(R.styleable.AppBarLayout_elevation, 0);
    setBackgroundDrawable(a.getDrawable(R.styleable.AppBarLayout_android_background));
    if (a.hasValue(R.styleable.AppBarLayout_expanded)) {
        setExpanded(a.getBoolean(R.styleable.AppBarLayout_expanded, false));
    }
    a.recycle();
    ViewUtils.setBoundsViewOutlineProvider(this);
    this.mListeners = new ArrayList();
    ViewCompat.setElevation(this, this.mTargetElevation);
    ViewCompat.setOnApplyWindowInsetsListener(this, new OnApplyWindowInsetsListener() {
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            return AppBarLayout.this.onWindowInsetChanged(insets);
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:AppBarLayout.java

示例2: onChildDraw

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onChildDraw(
        final Canvas c,
        final RecyclerView recyclerView,
        final RecyclerView.ViewHolder viewHolder,
        final float dX, final float dY,
        final int actionState,
        final boolean isCurrentlyActive) {

    if (isCurrentlyActive) {
        ViewCompat.setElevation(
                viewHolder.itemView,
                Math.min(
                        Math.max(dX / 4f, defaultElevation),
                        defaultElevation * 16f
                )
        );
    }

    super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
 
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:22,代码来源:OverviewActivity.java

示例3: setDrawerElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void setDrawerElevation(float elevation) {
    this.mDrawerElevation = elevation;
    for (int i = 0; i < getChildCount(); i++) {
        View child = getChildAt(i);
        if (isDrawerView(child)) {
            ViewCompat.setElevation(child, this.mDrawerElevation);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:DrawerLayout.java

示例4: onDraw

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public void onDraw(Canvas c, RecyclerView recyclerView, View view, float dX, float dY, int actionState, boolean isCurrentlyActive) {
    if (isCurrentlyActive && view.getTag(R.id.item_touch_helper_previous_elevation) == null) {
        Float originalElevation = Float.valueOf(ViewCompat.getElevation(view));
        ViewCompat.setElevation(view, 1.0f + findMaxElevation(recyclerView, view));
        view.setTag(R.id.item_touch_helper_previous_elevation, originalElevation);
    }
    super.onDraw(c, recyclerView, view, dX, dY, actionState, isCurrentlyActive);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:ItemTouchUIUtilImpl.java

示例5: setElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * modify the elevation of multiples views
 *
 * @param elevation the new elevation
 * @param views
 */
static void setElevation(float elevation, View... views) {
    for (View view : views) {
        if (view != null) {
            ViewCompat.setElevation(view, elevation);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:Utils.java

示例6: setBodyElevationPx

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void setBodyElevationPx(final int elevationPx) {
	this.bodyElevationPx = elevationPx;

	// Check must be done since the body may be null
	if (body != null) {
		ViewCompat.setElevation(body, DimensionHelper.dpToPx(getContext(), bodyElevationPx));
	}
}
 
开发者ID:MatthewTamlin,项目名称:Mixtape,代码行数:10,代码来源:CoordinatedMixtapeContainer.java

示例7: clearView

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void clearView(View view) {
    final Object tag = view.getTag();
    if (tag != null && tag instanceof Float) {
        ViewCompat.setElevation(view, (Float) tag);
    }
    view.setTag(null);
    super.clearView(view);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:10,代码来源:ItemTouchUIUtilImpl.java

示例8: setRoundingElevation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Sets the base elevation of this view, in pixels.
 *
 * @param elevation org.amphiaraus.roundedlayout.R.styleable#RoundedLayout_rlRoundingElevation
 */
public void setRoundingElevation(float elevation) {
    this.mRoundingElevation = elevation;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setElevation(elevation);
    } else {
        ViewCompat.setElevation(this, elevation);
    }
}
 
开发者ID:amphiaraus,项目名称:RoundedLayout,代码行数:14,代码来源:RoundedLayout.java

示例9: initView

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void initView(int elevation) {
    if (!isInEditMode()) {
        mTickView.setBackgroundColor(mStartColor);
        mTextMaskView.setBackgroundColor(mStartColor);
        mMaskView.setBackgroundColor(mStartColor);
    }
    ViewCompat.setElevation(mTickView, elevation);
    ViewCompat.setElevation(mTextMaskView, elevation);
    ViewCompat.setElevation(mMaskView, elevation);
}
 
开发者ID:kingwang666,项目名称:BookLoadingView,代码行数:11,代码来源:BookLoadingView.java

示例10: i

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void i() {
    helper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    // Add a dummy view that will receive inner touch events.
    View dummyView = new View(getContext());
    dummyBehavior = new DummyBehavior();
    // I *think* this is needed for dummyView to be identified as "topmost" and receive events
    // before any other view.
    ViewCompat.setElevation(dummyView, ViewCompat.getElevation(this));
    // Make sure it does not fit windows, or it will consume insets before the AppBarLayout.
    ViewCompat.setFitsSystemWindows(dummyView, false);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.setBehavior(dummyBehavior);
    addView(dummyView, params);
}
 
开发者ID:natario1,项目名称:NestedScrollCoordinatorLayout,代码行数:16,代码来源:NestedScrollCoordinatorLayout.java

示例11: SnackbarLayout

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public SnackbarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SnackbarLayout);
    this.mMaxWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_android_maxWidth, -1);
    this.mMaxInlineActionWidth = a.getDimensionPixelSize(R.styleable.SnackbarLayout_maxActionInlineWidth, -1);
    if (a.hasValue(R.styleable.SnackbarLayout_elevation)) {
        ViewCompat.setElevation(this, (float) a.getDimensionPixelSize(R.styleable.SnackbarLayout_elevation, 0));
    }
    a.recycle();
    setClickable(true);
    LayoutInflater.from(context).inflate(R.layout.design_layout_snackbar_include, this);
    ViewCompat.setAccessibilityLiveRegion(this, 1);
    ViewCompat.setImportantForAccessibility(this, 1);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:Snackbar.java

示例12: Marker

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
public Marker(Context context, AttributeSet attrs, int defStyleAttr, String maxValue, int thumbSize, int separation) {
    super(context, attrs, defStyleAttr);
    //as we're reading the parent DiscreteSeekBar attributes, it may wrongly set this view's visibility.
    setVisibility(View.VISIBLE);

    DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DiscreteSeekBar,
            R.attr.discreteSeekBarStyle, R.style.Widget_DiscreteSeekBar);

    int padding = (int) (PADDING_DP * displayMetrics.density) * 2;
    int textAppearanceId = a.getResourceId(R.styleable.DiscreteSeekBar_dsb_indicatorTextAppearance,
            R.style.Widget_DiscreteIndicatorTextAppearance);
    mNumber = new TextView(context);
    //Add some padding to this textView so the bubble has some space to breath
    mNumber.setPadding(padding, 0, padding, 0);
    mNumber.setTextAppearance(context, textAppearanceId);
    mNumber.setGravity(Gravity.CENTER);
    mNumber.setText(maxValue);
    mNumber.setMaxLines(1);
    mNumber.setSingleLine(true);
    SeekBarCompat.setTextDirection(mNumber, TEXT_DIRECTION_LOCALE);
    mNumber.setVisibility(View.INVISIBLE);

    //add some padding for the elevation shadow not to be clipped
    //I'm sure there are better ways of doing this...
    setPadding(padding, padding, padding, padding);

    resetSizes(maxValue);

    mSeparation = separation;
    ColorStateList color = a.getColorStateList(R.styleable.DiscreteSeekBar_dsb_indicatorColor);
    mMarkerDrawable = new MarkerDrawable(color, thumbSize);
    mMarkerDrawable.setCallback(this);
    mMarkerDrawable.setMarkerListener(this);
    mMarkerDrawable.setExternalOffset(padding);

    //Elevation for anroid 5+
    float elevation = a.getDimension(R.styleable.DiscreteSeekBar_dsb_indicatorElevation, ELEVATION_DP * displayMetrics.density);
    ViewCompat.setElevation(this, elevation);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        SeekBarCompat.setOutlineProvider(this, mMarkerDrawable);
    }
    a.recycle();
}
 
开发者ID:zacharee,项目名称:SliderPreferenceEmbedded,代码行数:45,代码来源:Marker.java

示例13: onAnimationEnd

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onAnimationEnd(Animation animation) {
    ViewCompat.setElevation(mToolbarContainer, 5);
    mToolbarContainer.setBackgroundColor(mColor); //elevation needs a background color
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:6,代码来源:VideoInfoActivityFragment.java

示例14: elevateNavigationView

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
private void elevateNavigationView() {
    if (mTabLayout != null) {
        ViewCompat.setElevation(mTabLayout, mElevation);
    }
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:6,代码来源:BottomNavigationBehavior.java

示例15: toggleActivation

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * Allows to change and see the activation status on the itemView and to perform animation
 * on inner views.
 * <p><b>IMPORTANT NOTE!</b> the selected background is visible if you added
 * {@code android:background="?attr/selectableItemBackground"} on the item layout <u>AND</u>
 * customized the file {@code style.xml}.</p>
 * Alternatively, to set a background at runtime, you can use the new
 * {@link eu.davidea.flexibleadapter.utils.DrawableUtils}.
 * <p><b>Note:</b> This method must be called every time we want the activation state visible
 * on the itemView, for instance: after a Click (to add the item to the selection list) or
 * after a LongClick (to activate the ActionMode) or during dragging (to show that we enabled
 * the Drag).</p>
 * If you follow the above instructions, it's not necessary to invalidate this view with
 * {@code notifyItemChanged}: In this way {@code bindViewHolder} won't be called and inner
 * views can animate without interruptions, eventually you will see the animation running
 * on those inner views at the same time of selection activation.
 *
 * @see #getActivationElevation()
 * @since 5.0.0-b1
 */
@CallSuper
public void toggleActivation() {
	// Only for selectable items
	int position = getFlexibleAdapterPosition();
	if (!mAdapter.isSelectable(position)) return;
	// [De]Activate the view
	boolean selected = mAdapter.isSelected(position);
	if (itemView.isActivated() && !selected || !itemView.isActivated() && selected) {
		itemView.setActivated(selected);
		// Apply elevation
		if (itemView.isActivated() && getActivationElevation() > 0)
			ViewCompat.setElevation(itemView, getActivationElevation());
		else if (getActivationElevation() > 0) //Leave unaltered the default elevation
			ViewCompat.setElevation(itemView, 0);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:FlexibleViewHolder.java


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