當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。