當前位置: 首頁>>代碼示例>>Java>>正文


Java GradientDrawable.setCornerRadii方法代碼示例

本文整理匯總了Java中android.graphics.drawable.GradientDrawable.setCornerRadii方法的典型用法代碼示例。如果您正苦於以下問題:Java GradientDrawable.setCornerRadii方法的具體用法?Java GradientDrawable.setCornerRadii怎麽用?Java GradientDrawable.setCornerRadii使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.GradientDrawable的用法示例。


在下文中一共展示了GradientDrawable.setCornerRadii方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: create

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
public Drawable create(Context context) {
  final GradientDrawable bubble = new GradientDrawable();
  final int              radius = context.getResources().getDimensionPixelSize(R.dimen.message_bubble_corner_radius);
  final float[]          radii  = cornerBooleansToRadii(corners, radius);

  bubble.setColor(color);
  bubble.setCornerRadii(radii);

  if (!hasShadow) {
    return bubble;
  } else {
    final GradientDrawable shadow   = new GradientDrawable();
    final int              distance = context.getResources().getDimensionPixelSize(R.dimen.message_bubble_shadow_distance);

    shadow.setColor(shadowColor);
    shadow.setCornerRadii(radii);

    final LayerDrawable layers = new LayerDrawable(new Drawable[]{shadow, bubble});
    layers.setLayerInset(1, 0, 0, 0, distance);
    return layers;
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:23,代碼來源:BubbleDrawableBuilder.java

示例2: getGradientDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private Drawable getGradientDrawable(float mCornerRadius,
                                     int mStrokeColor, int mSolidColor, int mStrokeWidth,
                                     float mDashWidth, float mDashGap,
                                     float mTopLeftRadius, float mTopRightRadius,
                                     float mBottomLeftRadius, float mBottomRightRadius) {
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(mSolidColor);
    gradientDrawable.setStroke(mStrokeWidth, mStrokeColor, mDashWidth, mDashGap);
    float[] radius = {mTopLeftRadius, mTopLeftRadius, mTopRightRadius, mTopRightRadius, mBottomRightRadius,
            mBottomRightRadius, mBottomLeftRadius, mBottomLeftRadius};

    if (mCornerRadius == DEFAULT_CORNER_RADIUS) {
        gradientDrawable.setCornerRadii(radius);
    } else {
        gradientDrawable.setCornerRadius(mCornerRadius);
    }
    return gradientDrawable;
}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:19,代碼來源:SuperConfig.java

示例3: setupGradientDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private void setupGradientDrawable(View view, float mCornerRadius,
                                   int mStrokeColor, int mSolidColor, int mStrokeWidth,

                                   float mDashWidth, float mDashGap,
                                   float mTopLeftRadius, float mTopRightRadius,
                                   float mBottomLeftRadius, float mBottomRightRadius) {
    mGradientDrawable = new GradientDrawable();
    mGradientDrawable.setColor(mSolidColor);
    mGradientDrawable.setStroke(mStrokeWidth, mStrokeColor, mDashWidth, mDashGap);
    float[] radius = {mTopLeftRadius, mTopLeftRadius, mTopRightRadius, mTopRightRadius, mBottomRightRadius,
            mBottomRightRadius, mBottomLeftRadius, mBottomLeftRadius};

    if (mCornerRadius == DEFAULT_CORNER_RADIUS) {
        mGradientDrawable.setCornerRadii(radius);
    } else {
        mGradientDrawable.setCornerRadius(mCornerRadius);
    }
    view.setBackgroundDrawable(mGradientDrawable);
}
 
開發者ID:z-chu,項目名稱:FriendBook,代碼行數:20,代碼來源:SuperConfig.java

示例4: setDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
/**
 * 設置 背景Drawable顏色線框色及圓角值
 *
 * @param gd
 * @param color
 * @param strokeColor
 */
private void setDrawable(GradientDrawable gd, int color, int strokeColor) {
    //任意值大於0執行
    if (topLeftRadius > 0 || topRightRadius > 0 || bottomRightRadius > 0 || bottomLeftRadius > 0) {
        radiusArr[0] = topLeftRadius;
        radiusArr[1] = topLeftRadius;
        radiusArr[2] = topRightRadius;
        radiusArr[3] = topRightRadius;
        radiusArr[4] = bottomRightRadius;
        radiusArr[5] = bottomRightRadius;
        radiusArr[6] = bottomLeftRadius;
        radiusArr[7] = bottomLeftRadius;
        gd.setCornerRadii(radiusArr);
    } else {
        gd.setCornerRadius(radius);
    }
    gd.setStroke(strokeWidth, strokeColor, strokeDashWidth, strokeDashGap);
    gd.setColor(color);
}
 
開發者ID:AriesHoo,項目名稱:UIWidget,代碼行數:26,代碼來源:RadiusViewDelegate.java

示例5: updateDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private void updateDrawable(int strokeColor) {

            int mbackgroundColor;
            if (isChecked) {
                mbackgroundColor = selectedBackgroundColor;
            } else {
                mbackgroundColor = backgroundColor;
            }

            GradientDrawable drawable = new GradientDrawable();
            drawable.setCornerRadii(mRadius);
            drawable.setColor(mbackgroundColor);
            drawable.setStroke(mStrokeWidth, strokeColor);

            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                this.setBackgroundDrawable(drawable);
            } else {
                this.setBackground(drawable);
            }
        }
 
開發者ID:Lazyeraser,項目名稱:DereHelper,代碼行數:21,代碼來源:MultiLineChooseLayout.java

示例6: rebuildBackgroundShape

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
/**
 * Rebuild the background shape based on config properties
 */
private void rebuildBackgroundShape() {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadii(getCornerRadii());
    shape.setColor(mFillColor);
    shape.setStroke(mStrokeWidth, mStrokeColor);
    setBackgroundDrawable(shape);
}
 
開發者ID:Seanalair,項目名稱:RoundedCornerFrameLayout,代碼行數:12,代碼來源:RoundedCornerFrameLayout.java

示例7: createTileShape

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private static Drawable createTileShape(int backgroundColor, int borderColor) {
	GradientDrawable shape = new GradientDrawable();
	shape.setShape(GradientDrawable.RECTANGLE);
	shape.setCornerRadii(new float[]{7, 7, 7, 7, 0, 0, 0, 0});
	shape.setColor(backgroundColor);
	shape.setStroke(1, borderColor);
	shape.setBounds(7, 7, 7, 7);
	return (shape);
}
 
開發者ID:alescdb,項目名稱:LauncherTV,代碼行數:10,代碼來源:ApplicationView.java

示例8: createDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private Drawable createDrawable(Drawable drawable, int backgroundColor, int borderColor, boolean forceToColorMode) {
    if (!(drawable instanceof GradientDrawable) && !forceToColorMode) {
        return drawable;
    }

    GradientDrawable gradientDrawable = new GradientDrawable();

    gradientDrawable.setColor(backgroundColor);
    gradientDrawable.setStroke(mBdWidth, borderColor, mBdDashWidth, mBdDashGap);

    if (mCRTopLeft == mCRTopRight
            && mCRTopRight == mCRBottomRight
            && mCRBottomRight == mCRBottomLeft) {
        gradientDrawable.setCornerRadius(mCRTopLeft);
    } else {
        float[] cornerArray = new float[8];
        cornerArray[0] = mCRTopLeft;
        cornerArray[1] = mCRTopLeft;
        cornerArray[2] = mCRTopRight;
        cornerArray[3] = mCRTopRight;
        cornerArray[4] = mCRBottomRight;
        cornerArray[5] = mCRBottomRight;
        cornerArray[6] = mCRBottomLeft;
        cornerArray[7] = mCRBottomLeft;
        gradientDrawable.setCornerRadii(cornerArray);
    }

    return gradientDrawable;
}
 
開發者ID:uccmawei,項目名稱:ColorView,代碼行數:30,代碼來源:ColorViewHelper.java

示例9: CT

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
public CT(Builder builder) {
    LayoutInflater inflater = (LayoutInflater) builder.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.custom_layout, null);
    TextView tv = layout.findViewById(R.id.cltv);
    tv.setText(builder.text);
    tv.setTextColor(builder.textCol);

    ImageView iv = layout.findViewById(R.id.cliv);
    iv.setImageResource(builder.imageRes);


    GradientDrawable shape = new GradientDrawable();
    shape.setShape(builder.shape);
    shape.setCornerRadii(new float[]{
            builder.radiusTopLeft,
            builder.radiusTopLeft,
            builder.radiusTopRight,
            builder.radiusTopRight,
            builder.radiusBottomRight,
            builder.radiusBottomRight,
            builder.radiusBottomLeft,
            builder.radiusBottomLeft
    });
    shape.setColor(builder.backCol);
    shape.setStroke(builder.borderWidth, builder.borderCol);

    layout.setBackgroundDrawable(shape);
    Toast toast = new Toast(builder.context);
    toast.setView(layout);
    toast.setDuration(builder.toastDuration);
    toast.setGravity(builder.toastGravity,0,100);
    toast.show();
}
 
開發者ID:shivam301296,項目名稱:Android-CustomToast,代碼行數:35,代碼來源:CT.java

示例10: getCornerDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private Drawable getCornerDrawable(boolean selected, float[] cornerRadii) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setColor(selected ? colorSelected : colorUnselected);
    drawable.setCornerRadii(cornerRadii);
    drawable.setStroke(strokeWidth, colorSelected);
    return drawable;
}
 
開發者ID:ImDobyDad,項目名稱:SingleSelectBar,代碼行數:8,代碼來源:ResHelper.java

示例11: initView

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
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,代碼行數:41,代碼來源:RoundRelativeLayout.java

示例12: setBackground

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
public static Drawable setBackground(View v, int color, int borderColor, int r, int borderStroke) {
	GradientDrawable shape = new GradientDrawable();
	shape.setShape(GradientDrawable.RECTANGLE);
	shape.setCornerRadii(new float[] { r, r, r, r, r, r, r, r });
	shape.setColor(color);
	shape.setStroke(borderStroke, borderColor);
	return shape;
}
 
開發者ID:Taishi-Y,項目名稱:FlipProgressDialog,代碼行數:9,代碼來源:BackgroundView.java

示例13: cornerDrawable

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
public static Drawable cornerDrawable(final int bgColor, float[] cornerradius) {
    final GradientDrawable bg = new GradientDrawable();
    bg.setCornerRadii(cornerradius);
    bg.setColor(bgColor);

    return bg;
}
 
開發者ID:Luodian,項目名稱:Shared-Route,代碼行數:8,代碼來源:CornerUtils.java

示例14: initData

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
private void initData(Context context, AttributeSet attrs) {
    setClickable(true);
    normalTextColor = getCurrentTextColor();
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ShapeView);
    touchTextColor = a.getColor(R.styleable.ShapeView_touchTextColor, getCurrentTextColor());
    solidColor = a.getColor(R.styleable.ShapeView_solidColor, Color.GRAY);
    stroke_Color = a.getColor(R.styleable.ShapeView_stroke_Color, Color.TRANSPARENT);
    touchColor = a.getColor(R.styleable.ShapeView_touchSolidColor, Color.TRANSPARENT);
    enableColor = a.getColor(R.styleable.ShapeView_enableColor, solidColor);
    enableTextColor = a.getColor(R.styleable.ShapeView_enableTextColor, getCurrentTextColor());
    cornesRadius = (int) a.getDimension(R.styleable.ShapeView_cornesRadius, 0);
    topLeftRadius = (int) a.getDimension(R.styleable.ShapeView_topLeftRadius, 0);
    topRightRadius = (int) a.getDimension(R.styleable.ShapeView_topRightRadius, 0);
    bottomLeftRadius = (int) a.getDimension(R.styleable.ShapeView_bottomLeftRadius, 0);
    bottomRightRadius = (int) a.getDimension(R.styleable.ShapeView_bottomRightRadius, 0);
    stroke_Width = (int) a.getDimension(R.styleable.ShapeView_stroke_Width, 0);
    strokeDashWidth = (int) a.getDimension(R.styleable.ShapeView_strokeDashWidth, 0);
    strokeDashGap = (int) a.getDimension(R.styleable.ShapeView_strokeDashGap, 0);
    shapeType = a.getInt(R.styleable.ShapeView_shapeType, -1);
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setStroke(stroke_Width, stroke_Color, strokeDashWidth, strokeDashGap);

    if (!isEnabled()) {
        gradientDrawable.setColor(enableColor);
        setTextColor(enableTextColor);
    } else {
        gradientDrawable.setColor(solidColor);
        setTextColor(normalTextColor);
    }
    if (shapeType != -1) {
        gradientDrawable.setShape(shapeType);
    }
    if (shapeType != GradientDrawable.OVAL) {
        if (cornesRadius != 0) {
            gradientDrawable.setCornerRadius(cornesRadius);
        } else {
            //1、2兩個參數表示左上角,3、4表示右上角,5、6表示右下角,7、8表示左下角
            gradientDrawable.setCornerRadii(new float[]{topLeftRadius, topLeftRadius, topRightRadius, topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius});
        }
    }
    setBackgroundDrawable(gradientDrawable);

}
 
開發者ID:JJS-CN,項目名稱:JBase,代碼行數:44,代碼來源:ShapeView.java

示例15: initView

import android.graphics.drawable.GradientDrawable; //導入方法依賴的package包/類
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,代碼行數:43,代碼來源:RoundLinearLayout.java


注:本文中的android.graphics.drawable.GradientDrawable.setCornerRadii方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。