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


Java GradientDrawable.setShape方法代码示例

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


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

示例1: addPulseRing

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void addPulseRing(LatLng latLng) {
    GradientDrawable d = new GradientDrawable();
    d.setShape(GradientDrawable.OVAL);
    d.setSize(500, 500);
    d.setColor(ContextCompat.getColor(this, R.color.pulse_color));

    Bitmap bitmap = Bitmap.createBitmap(d.getIntrinsicWidth()
            , d.getIntrinsicHeight()
            , Bitmap.Config.ARGB_8888);

    // Convert the drawable to bitmap
    Canvas canvas = new Canvas(bitmap);
    d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    d.draw(canvas);

    // Radius of the circle
    final int radius = 100;

    // Add the circle to the map
    circle = mMap.addGroundOverlay(new GroundOverlayOptions()
            .position(latLng, 2 * radius).image(BitmapDescriptorFactory.fromBitmap(bitmap)));
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:23,代码来源:Home.java

示例2: initBorder

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void initBorder() {
//        if (mWipeOffBorder || mIdentity == null || !mIdentity.officialMember) {
//            mDrawable = null;
//            setBackground(null);
//            return;
//        }

        if (mDrawable == null) {
            float radius = 4f;

            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
            gradientDrawable.setShape(GradientDrawable.RECTANGLE);
            gradientDrawable.setDither(true);
            gradientDrawable.setStroke(STROKE_SIZE, mColor);
            gradientDrawable.setCornerRadius(radius);

            mDrawable = gradientDrawable;
        } else {
            mDrawable.setStroke(STROKE_SIZE, mColor);
        }

        setBackground(mDrawable);
    }
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:25,代码来源:IdentityView.java

示例3: getBadgeDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * @param context to fetch color
 * @return return the background drawable
 */
private GradientDrawable getBadgeDrawable(Context context) {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadius(context.getResources().getDimensionPixelSize(R.dimen.badge_corner_radius));
    shape.setColor(getBackgroundColor(context));
    shape.setStroke(getBorderWidth(), getBorderColor(context));
    return shape;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:TextBadgeItem.java

示例4: 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

示例5: createDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * 效果比createSolidDrawable好
 */
public static Drawable createDrawable(int solidColor, float radii) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(GradientDrawable.RECTANGLE);//设置形状
    drawable.setCornerRadius(radii);
    drawable.setColor(solidColor);//请不要用透明颜色试图隐藏solid
    return drawable;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:11,代码来源:ResUtil.java

示例6: createBackgroundColorDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private Drawable createBackgroundColorDrawable() {
    GradientDrawable mask = new GradientDrawable();
    mask.setShape(GradientDrawable.OVAL);
    if (mOutlineWidth != 0) {
        mask.setStroke(mOutlineWidth, isColorDark(mColor) ? Color.WHITE : Color.BLACK);
    }
    mask.setColor(mColor);
    return mask;
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:10,代码来源:ColorView.java

示例7: createButtonBackgroundDrawableBase

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private static Drawable createButtonBackgroundDrawableBase(int color, int cornerRadius) {
    GradientDrawable d = new GradientDrawable();
    d.setShape(GradientDrawable.RECTANGLE);
    d.setCornerRadius(cornerRadius);
    d.setColor(color);
    return d;
}
 
开发者ID:myinnos,项目名称:ImageSaveandShare,代码行数:8,代码来源:UtilsLibrary.java

示例8: createStateListDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
 * @param radius 圆角角度
 * @param color  填充颜色
 * @return StateListDrawable 对象
 * @author zy
 */
public static StateListDrawable createStateListDrawable(int radius, int color) {
    StateListDrawable bg = new StateListDrawable();
    GradientDrawable gradientStateNormal = new GradientDrawable();
    gradientStateNormal.setColor(color);
    gradientStateNormal.setShape(GradientDrawable.RECTANGLE);
    gradientStateNormal.setCornerRadius(50);
    gradientStateNormal.setStroke(0, 0);
    bg.addState(View.EMPTY_STATE_SET, gradientStateNormal);
    return bg;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:17,代码来源:DragPointView.java

示例9: getGradientDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public GradientDrawable getGradientDrawable(int strokeWidth,int strokeColor,int fillColor){
    GradientDrawable gd = new GradientDrawable();//创建drawable
    gd.setColor(fillColor);
    gd.setShape(GradientDrawable.OVAL);
    gd.setSize(100, 100);
    gd.setStroke(strokeWidth, strokeColor);
    return gd;
}
 
开发者ID:yaokantv,项目名称:YKCenterSDKExample_for_AS,代码行数:9,代码来源:AnimStudy.java

示例10: 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

示例11: 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

示例12: getItemShape

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private GradientDrawable getItemShape(int shape, int cornerRadius,
                                      int solidColor, int strokeWidth, int strokeColor) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(shape);
    drawable.setStroke(strokeWidth, strokeColor);
    drawable.setCornerRadius(cornerRadius);
    drawable.setColor(solidColor);
    return drawable;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:10,代码来源:SelectorFactory.java

示例13: addMenuView

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void addMenuView(Context context, ImageView iv, TextView tv, boolean show) {
        //SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
        //int cColor = themePrefs.getInt("chatsHeaderTabCounterColor", 0xffffffff);
        //int bgColor = themePrefs.getInt("chatsHeaderTabCounterBGColor", 0xffff0000);

        iv.setScaleType(ImageView.ScaleType.CENTER);
        //int size = themePrefs.getInt("chatsHeaderTabCounterSize", 11);
        //tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, size);
        tv.setGravity(Gravity.RIGHT);
        //tv.setTextColor(cColor);

        GradientDrawable shape = new GradientDrawable();
        shape.setShape(GradientDrawable.RECTANGLE);
        shape.setCornerRadius(AndroidUtilities.dp(32));
        //shape.setColor(bgColor);

        tv.setBackgroundDrawable(shape);
        //tv.setPadding(AndroidUtilities.dp(size > 10 ? size - 7 : 4), 0, AndroidUtilities.dp(size > 10 ? size - 7 : 4), 0);
        RelativeLayout layout = new RelativeLayout(context);
        layout.addView(iv, LayoutHelper.createRelative(50, LayoutHelper.MATCH_PARENT));
        layout.addView(tv, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 10, 5, 0, RelativeLayout.ALIGN_PARENT_RIGHT));
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams();
        params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
        tv.setLayoutParams(params);
        if (show) {
            menu.addView(layout, LayoutHelper.createLinear(50, LayoutHelper.MATCH_PARENT, 0));
        }

//        MenuCount(notifsCounter);

    }
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:32,代码来源:DialogsActivity.java

示例14: getIcFolderSelectedDrawable

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public static GradientDrawable getIcFolderSelectedDrawable( int color){
    GradientDrawable gradientDrawable=new GradientDrawable();
    gradientDrawable.setShape(GradientDrawable.OVAL);
    gradientDrawable.setSize(SizeUtils.dp2px(24), SizeUtils.dp2px(24));
    gradientDrawable.setBounds(0,0,SizeUtils.dp2px(24), SizeUtils.dp2px(24));
    gradientDrawable.setColor(color);
    return gradientDrawable;
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:9,代码来源:MyDrawable.java

示例15: refreshWeightProgress

import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void refreshWeightProgress() {
    if (this.mUser != null && !isRemoved()) {
        float latestWeight = getLatestWeight();
        GradientDrawable drawable = new GradientDrawable();
        drawable.setShape(1);
        drawable.setColor(ViewCompat.MEASURED_SIZE_MASK);
        float delta;
        if (this.mUser.target_weight == -1.0f) {
            this.tvProgress.setText("保持/塑形");
            delta = latestWeight - this.mUser.begin_weight;
            if (delta <= 0.0f) {
                drawable.setStroke(5, getResources().getColor(R.color.hb));
                this.tvDes.setText("比上次轻");
            } else {
                drawable.setStroke(5, getResources().getColor(R.color.jr));
                this.tvDes.setText("比上次重");
            }
            this.tvWeight.setText(NumberUtils.safeToString(this.dFormat, (double) Math.abs
                    (delta)));
            this.arcProgress.setVisibility(8);
        } else {
            float progress;
            drawable.setStroke(1, 2113929215);
            delta = latestWeight - this.mUser.begin_weight;
            this.tvWeight.setText(NumberUtils.safeToString(this.dFormat, (double) Math.abs
                    (delta)));
            if (delta <= 0.0f) {
                this.tvDes.setText("已减重");
            } else {
                this.tvDes.setText("已增重");
            }
            if (this.mUser.begin_weight - latestWeight < 0.0f) {
                progress = -1.0f;
            } else if (this.mUser.begin_weight - this.mUser.target_weight <= 0.0f) {
                progress = 0.0f;
            } else {
                progress = (this.mUser.begin_weight - latestWeight) / (this.mUser
                        .begin_weight - this.mUser.target_weight);
            }
            this.arcProgress.setVisibility(0);
            this.arcProgress.setProgress(progress);
            this.tvWeight.setText(NumberUtils.safeToString(this.dFormat, (double) Math.abs
                    (delta)));
            this.tvProgress.setText(String.format("目标完成%d%%", new Object[]{Integer.valueOf
                    (Math.min(Math.max((int) (100.0f * progress), 0), 100))}));
        }
        this.rlProgress.setBackgroundDrawable(drawable);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:50,代码来源:HomeNewFragment.java


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