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


Java GradientDrawable.RECTANGLE属性代码示例

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


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

示例1: ShapeSelector

private ShapeSelector() {
    //initialize default values
    mShape = GradientDrawable.RECTANGLE;
    mDefaultBgColor = Color.TRANSPARENT;
    mDisabledBgColor = Color.TRANSPARENT;
    mPressedBgColor = Color.TRANSPARENT;
    mSelectedBgColor = Color.TRANSPARENT;
    mFocusedBgColor = Color.TRANSPARENT;
    mStrokeWidth = 0;
    mDefaultStrokeColor = Color.TRANSPARENT;
    mDisabledStrokeColor = Color.TRANSPARENT;
    mPressedStrokeColor = Color.TRANSPARENT;
    mSelectedStrokeColor = Color.TRANSPARENT;
    mFocusedStrokeColor = Color.TRANSPARENT;
    mCornerRadius = 0;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:16,代码来源:SelectorFactory.java

示例2: Builder

public Builder(Context context, String text) {
    this.context = context;
    this.text = text;

    shape = GradientDrawable.RECTANGLE;
    backCol = Color.WHITE;
    borderCol = Color.BLACK;
    textCol = Color.BLACK;
    imageRes = 0;
}
 
开发者ID:shivam301296,项目名称:Android-CustomToast,代码行数:10,代码来源:CT.java

示例3: initView

private void initView(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundLatout);
    //显示类型
    int shapeTpe = a.getInt(R.styleable.RoundLatout_viewShapeTpe, shapeTypes[0]);
    //圆角大小
    float cornerRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewCornerRadius, 0);
    float topLeftRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewTopLeftRadius, 0);
    float topRightRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewTopRightRadius, 0);
    float bottomLeftRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewBottomLeftRadius, 0);
    float bottomRightRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewBottomRightRadius, 0);

    //填充色
    int solidColor = a.getColor(R.styleable.RoundLatout_viewSolidColor, 0x0);
    //边框
    int strokeColor = a.getColor(R.styleable.RoundLatout_viewStrokeColor, 0x0);
    int strokeWidth = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeWidth, 0);
    int strokeDashWidth = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeDashWidth, 0);
    int strokeDashGap = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeDashGap, 0);

    a.recycle();

    GradientDrawable gd = new GradientDrawable();

    gd.setColor(solidColor);
    //设置类型
    gd.setShape(shapeTypes[shapeTpe]);
    //类型为矩形才可设置圆角
    if (shapeTypes[shapeTpe] == GradientDrawable.RECTANGLE) {
        if (cornerRadius != 0) {
            gd.setCornerRadius(cornerRadius);
        } else {
            gd.setCornerRadii(new float[]{topLeftRadius, topLeftRadius, topRightRadius, topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius});
        }
    }

    gd.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeDashGap);


    setBackground(gd);
}
 
开发者ID:ZQ7,项目名称:RoundView,代码行数:40,代码来源:RoundRelativeLayout.java

示例4: initView

private void initView(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundLatout);
    //显示类型
    int shapeTpe = a.getInt(R.styleable.RoundLatout_viewShapeTpe, shapeTypes[0]);
    //圆角大小
    float cornerRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewCornerRadius, 0);
    float topLeftRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewTopLeftRadius, 0);
    float topRightRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewTopRightRadius, 0);
    float bottomLeftRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewBottomLeftRadius, 0);
    float bottomRightRadius = a.getLayoutDimension(R.styleable.RoundLatout_viewBottomRightRadius, 0);

    //填充色
    int solidColor = a.getColor(R.styleable.RoundLatout_viewSolidColor, 0x0);
    //边框
    int strokeColor = a.getColor(R.styleable.RoundLatout_viewStrokeColor, 0x0);
    int strokeWidth = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeWidth, 0);
    int strokeDashWidth = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeDashWidth, 0);
    int strokeDashGap = a.getDimensionPixelSize(R.styleable.RoundLatout_viewStrokeDashGap, 0);

    a.recycle();


    GradientDrawable gd = new GradientDrawable();

    gd.setColor(solidColor);
    //设置类型
    gd.setShape(shapeTypes[shapeTpe]);
    //类型为矩形才可设置圆角
    if (shapeTypes[shapeTpe] == GradientDrawable.RECTANGLE) {
        if (cornerRadius != 0) {
            gd.setCornerRadius(cornerRadius);
        } else {
            gd.setCornerRadii(new float[]{topLeftRadius, topLeftRadius, topRightRadius, topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius});
        }
    }


    gd.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeDashGap);


    setBackground(gd);
}
 
开发者ID:ZQ7,项目名称:RoundView,代码行数:42,代码来源:RoundLinearLayout.java


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