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


Java Outline类代码示例

本文整理汇总了Java中android.graphics.Outline的典型用法代码示例。如果您正苦于以下问题:Java Outline类的具体用法?Java Outline怎么用?Java Outline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: initialize

import android.graphics.Outline; //导入依赖的package包/类
private void initialize() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(new ViewOutlineProvider() {
            @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(
                        view.getPaddingLeft(),
                        view.getPaddingTop(),
                        view.getWidth() - view.getPaddingRight(),
                        view.getHeight() - view.getPaddingBottom());
            }
        });
        setClipToOutline(true);
    }
}
 
开发者ID:WangDaYeeeeee,项目名称:Mysplash,代码行数:17,代码来源:CircleImageView.java

示例2: HeaderElevationController

import android.graphics.Outline; //导入依赖的package包/类
HeaderElevationController(View header) {
    mHeader = header;
    final Resources res = mHeader.getContext().getResources();
    mMaxElevation = res.getDimension(R.dimen.all_apps_header_max_elevation);
    mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);

    // We need to provide a custom outline so the shadow only appears on the bottom edge.
    // The top, left and right edges are all extended out, and the shadow is clipped
    // by the parent.
    final ViewOutlineProvider vop = new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            final View parent = (View) mHeader.getParent();

            final int left = parent.getLeft(); // Use the parent to account for offsets
            final int top = view.getTop();
            final int right = left + view.getWidth();
            final int bottom = view.getBottom();

            final int offset = Utilities.pxFromDp(mMaxElevation, res.getDisplayMetrics());
            outline.setRect(left - offset, top - offset, right + offset, bottom);
        }
    };
    mHeader.setOutlineProvider(vop);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:26,代码来源:HeaderElevationController.java

示例3: onSizeChanged

import android.graphics.Outline; //导入依赖的package包/类
@Override
protected void onSizeChanged(final int w, final int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mDrawable.setBounds(0, 0, w, h);
    mWidth = w;
    mHeight = h;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setOutlineProvider(new ViewOutlineProvider() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
    }
}
 
开发者ID:dibakarece,项目名称:DMAudioStreamer,代码行数:19,代码来源:PlayPauseView.java

示例4: initView

import android.graphics.Outline; //导入依赖的package包/类
private void initView(AttributeSet attrs) {

        edgePaint.setColor(DEFAULT_EDGE_COLOR);
        edgePaint.setAntiAlias(true);
        if (attrs != null) {
            TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthView);
            edgePaint.setColor(arr.getInt(R.styleable.DepthView_edge_color, DEFAULT_EDGE_COLOR));
            setIsCircle(arr.getBoolean(R.styleable.DepthView_is_circle, false));
            depth = arr.getDimension(R.styleable.DepthView_depth, DEFAULT_THICKNESS * getResources().getDisplayMetrics().density);
            customShadowElevation = arr.getDimension(R.styleable.DepthView_custom_elevation, 0);
        } else {
            edgePaint.setColor(DEFAULT_EDGE_COLOR);
            depth = DEFAULT_THICKNESS * getResources().getDisplayMetrics().density;
        }
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {

            }
        });
    }
 
开发者ID:MSay2,项目名称:Mire,代码行数:22,代码来源:DepthLayout.java

示例5: initView

import android.graphics.Outline; //导入依赖的package包/类
private void initView(AttributeSet attrs) 
{

       edgePaint.setColor(DEFAULT_EDGE_COLOR);
       edgePaint.setAntiAlias(true);
       if (attrs != null)
	{
           TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthView);
           edgePaint.setColor(arr.getInt(R.styleable.DepthView_edge_color, DEFAULT_EDGE_COLOR));
           setIsCircle(arr.getBoolean(R.styleable.DepthView_is_circle, false));
           depth = arr.getDimension(R.styleable.DepthView_depth, DEFAULT_THICKNESS * getResources().getDisplayMetrics().density);
           customShadowElevation = arr.getDimension(R.styleable.DepthView_custom_elevation, 0);
       }
	else
	{
           edgePaint.setColor(DEFAULT_EDGE_COLOR);
           depth = DEFAULT_THICKNESS * getResources().getDisplayMetrics().density;
       }
	
       setOutlineProvider(new ViewOutlineProvider() 
	{
		@Override
		public void getOutline(View view, Outline outline)
		{ }
	});
   }
 
开发者ID:MSay2,项目名称:Mire,代码行数:27,代码来源:DepthFAB.java

示例6: createFillDrawable

import android.graphics.Outline; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{-android.R.attr.state_enabled}, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[]{android.R.attr.state_pressed}, createCircleDrawable(mColorPressed));
    drawable.addState(new int[]{}, createCircleDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:25,代码来源:FloatingActionButton.java

示例7: createFillDrawable

import android.graphics.Outline; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{android.R.attr.state_pressed}, createRectDrawable(mColorPressed));
    drawable.addState(new int[]{}, createRectDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:24,代码来源:Label.java

示例8: initView

import android.graphics.Outline; //导入依赖的package包/类
private void initView(AttributeSet attrs) {

        setLayerType(LAYER_TYPE_HARDWARE, null);

        edgePaint.setColor(DEFAULT_EDGE_COLOR);
        edgePaint.setAntiAlias(true);
        if (attrs != null) {
            TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthRelativeLayout);
            edgePaint.setColor(arr.getInt(R.styleable.DepthRelativeLayout_depth_edgeColor, DEFAULT_EDGE_COLOR));
            setIsCircle(arr.getBoolean(R.styleable.DepthRelativeLayout_depth_isCircle, false));
            depth = arr.getDimension(R.styleable.DepthRelativeLayout_depth_value, DEFAULT_THICKNESS * getResources().getDisplayMetrics().density);
            depthIndex = arr.getInteger(R.styleable.DepthRelativeLayout_depth_zIndex, depthIndex);
            animationDelay = arr.getInteger(R.styleable.DepthRelativeLayout_depth_animationDelay, animationDelay);
            customShadowElevation = arr.getDimension(R.styleable.DepthRelativeLayout_depth_elevation, 0);
        } else {
            edgePaint.setColor(DEFAULT_EDGE_COLOR);
            depth = DEFAULT_THICKNESS * getResources().getDisplayMetrics().density;
        }
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {

            }
        });
    }
 
开发者ID:florent37,项目名称:Depth,代码行数:26,代码来源:DepthRelativeLayout.java

示例9: getOutlineProvider

import android.graphics.Outline; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ViewOutlineProvider getOutlineProvider() {
    shadowpath = new Path();
    if (config.getRadius() == 0) {
        shadowpath = path;
    } else {
        rect = new Rect(0, 0, (int) width, (int) height);
        RectF r = new RectF(rect);
        shadowpath.addRoundRect(r, config.getRadius(), config.getRadius(), Path.Direction.CCW);
        shadowpath.op(path, shadowpath, Path.Op.INTERSECT);
    }
    return new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            if (path.isConvex()) {
                outline.setConvexPath(shadowpath);
            }
        }
    };
}
 
开发者ID:akshay2211,项目名称:Oblique,代码行数:22,代码来源:ObliqueView.java

示例10: initialize

import android.graphics.Outline; //导入依赖的package包/类
private void initialize() {

        borderPath = new Path();
        oval = new RectF();

        borderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        borderPaint.setStyle(Paint.Style.STROKE);

        // ViewOutlineProvider does not support clipping customized path
        if (canUseViewOutlineProvider()) {
            ViewOutlineProvider provider = new ViewOutlineProvider() {
                @Override
                public void getOutline(View view, Outline outline) {

                    if (canUseViewOutlineProvider()) {
                        float radius = Math.max(0, cornerRadius);
                        outline.setRoundRect(0, 0, getWidth(), getHeight(), radius);
                    }
                }
            };

            setOutlineProvider(provider);
            setClipToOutline(true);
        }
    }
 
开发者ID:QuarkWorks,项目名称:RoundedFrameLayout-Android,代码行数:26,代码来源:RoundedFrameLayout.java

示例11: createFillDrawable

import android.graphics.Outline; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{-android.R.attr.state_enabled}, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[]{android.R.attr.state_pressed}, createCircleDrawable(mColorPressed));
    drawable.addState(new int[]{}, createCircleDrawable(mColorNormal));

    if (!isInEditMode() && Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
开发者ID:AndroidDeveloperLB,项目名称:FloatingActionButtonEx,代码行数:25,代码来源:FloatingActionButton.java

示例12: createFillDrawable

import android.graphics.Outline; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[] {android.R.attr.state_pressed},
            createRectDrawable(mColorPressed)
    );
    drawable.addState(new int[] {}, createRectDrawable(mColorNormal));

    if(Util.hasLollipop() && mUsingRipple) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][] {{}},
                new int[] {mColorRipple}
        ), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
开发者ID:tpb1908,项目名称:AndroidProjectsClient,代码行数:27,代码来源:Label.java

示例13: initOutlineProvider

import android.graphics.Outline; //导入依赖的package包/类
private void initOutlineProvider() {
  if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
    setOutlineProvider(
        new ViewOutlineProvider() {
          @Override
          @TargetApi(Build.VERSION_CODES.LOLLIPOP)
          public void getOutline(View view, Outline outline) {
            if (chipDrawable != null) {
              chipDrawable.getOutline(outline);
            } else {
              outline.setAlpha(0.0f);
            }
          }
        });
  }
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:17,代码来源:Chip.java

示例14: calculateLayout

import android.graphics.Outline; //导入依赖的package包/类
private void calculateLayout() {
    if (settings == null) {
        return;
    }
    height = getMeasuredHeight();
    width = getMeasuredWidth();
    if (width > 0 && height > 0) {

        clipPath = createClipPath();
        ViewCompat.setElevation(this, settings.getElevation());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !settings.isCropInside()) {
            ViewCompat.setElevation(this, settings.getElevation());
            setOutlineProvider(new ViewOutlineProvider() {
                @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void getOutline(View view, Outline outline) {
                    outline.setConvexPath(clipPath);
                }
            });
        }
    }
}
 
开发者ID:florent37,项目名称:ArcLayout,代码行数:23,代码来源:ArcLayout.java

示例15: getOutline

import android.graphics.Outline; //导入依赖的package包/类
/**
 * Populates <code>outline</code> with the first available (non-empty) layer outline.
 *
 * @param outline Outline in which to place the first available layer outline
 */
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void getOutline(@NonNull Outline outline) {
    final ChildDrawable[] array = mLayerState.mChildren;
    final int N = mLayerState.mNum;
    for (int i = 0; i < N; i++) {
        final Drawable dr = array[i].mDrawable;
        if (dr != null) {
            dr.getOutline(outline);
            if (!outline.isEmpty()) {
                return;
            }
        }
    }
}
 
开发者ID:ZieIony,项目名称:Carbon,代码行数:21,代码来源:LayerDrawable.java


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