SoFunction
Updated on 2025-04-11

Android implements desktop unread corner markers

On Xiaomi, Samsung, Sony Mobile: Numbers (number of unread messages) are displayed on the icon: This part of the code is found in QQ5.

Xiaomi has passed the test.

Samsung and Sony have no corresponding phones and no tests. Some may modify the code (judging which phone code is).

Test it, you can reply to the test results, thank you

1. Native system (native Launcher), you can only modify shortcuts, and there will be toast prompts when adding and deleting them.

2. Xiaomi, Samsung, Sony Mobile: Custom Launcher: The action to send the number of unread messages is already different.For details, you can look at the code. . .

Determine the phone code:

/***
      * Add numbers to the shortcut to the application icon
      * @param clazz started activity
      * @param isShowNum Whether to display numbers
      * @param num Number displayed: integer
      * @param isStroke Whether to add borders
      *
      */
    public static void addNumShortCut(Context context,Class<?> clazz,boolean isShowNum, String num, boolean isStroke)
     {
         (TAG, "manufacturer="+);
      if (("Xiaomi")){
          //Millet       xiaoMiShortCut(context, clazz, num);

      }else if(("samsung")){
          //Samsung          samsungShortCut(context, num);

      }else {//Other native system mobile phones          installRawShortCut(context, , isShowNum, num, isStroke);
      }

     }

The tool class written below is also included in the above method.

/***
 * Application shortcut tool class
 *
 * @author yang
 *
 */
public class AppShortCutUtil {

    private static final String TAG = "AppShortCutUtil";

    //Default rounded corner radius    private static final int DEFAULT_CORNER_RADIUS_DIP = 8;
    //Default border width    private static final int DEFAULT_STROKE_WIDTH_DIP = 2;
    //Border color    private static final int DEFAULT_STROKE_COLOR = ;
    //The color of the middle number    private static final int DEFAULT_NUM_COLOR = ("#CCFF0000");

    /***
      *
      * Generate a picture with numbers (no border)
      * @param context
      * @param icon Image
      * @param isShowNum Do you want to draw numbers
      * @param num Number string: integer number exceeds 99, displayed as "99+"
      * @return
      */
    public static Bitmap generatorNumIcon(Context context, Bitmap icon, boolean isShowNum, String num) {

        DisplayMetrics dm = ().getDisplayMetrics();
        //Basic screen density        float baseDensity = 1.5f;//240dpi
        float factor = /baseDensity;

        (TAG, "density:"+);
        (TAG, "dpi:"+);
        (TAG, "factor:"+factor);

        // Initialize the canvas        int iconSize = (int) ().getDimension(.app_icon_size);
        Bitmap numIcon = (iconSize, iconSize, Config.ARGB_8888);
        Canvas canvas = new Canvas(numIcon);

        // Copy the picture        Paint iconPaint = new Paint();
        (true);// Anti-shake        (true);// Used to filter Bitmap, so that when you choose Drawable, there will be an anti-aliasing effect        Rect src = new Rect(0, 0, (), ());
        Rect dst = new Rect(0, 0, iconSize, iconSize);
        (icon, src, dst, iconPaint);

        if(isShowNum){

            if((num)){
                num = "0";
            }

            if(!(num)){
                //Non-number                (TAG, "the num is not digit :"+ num);
                num = "0";
            }

            int numInt = (num);

            if(numInt > 99){//More than 99
                num = "99+";

                // Enable anti-aliasing and use the device's text font size                Paint numPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
                ();
                (20f*factor);
                (Typeface.DEFAULT_BOLD);
                int textWidth=(int)(num, 0, ());

                (TAG, "text width:"+textWidth);

                int circleCenter = (int) (15*factor);//Central coordinate                int circleRadius = (int) (13*factor);//The radius of the circle
                //Draw the circle on the left                Paint leftCirPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                ();
                (iconSize-circleRadius-textWidth+(10*factor), circleCenter, circleRadius, leftCirPaint);

                //Draw the circle on the right                Paint rightCirPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                ();
                (iconSize-circleRadius, circleCenter, circleRadius, rightCirPaint);

                //Draw the middle distance                Paint rectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                ();
                RectF oval = new RectF(iconSize-circleRadius-textWidth+(10*factor), 2*factor, iconSize-circleRadius, circleRadius*2+2*factor);
                (oval, rectPaint);

                //Draw numbers                (num, (float)(iconSize-textWidth/2-(24*factor)), 23*factor,    numPaint);

            }else{//<=99

                // Enable anti-aliasing and use the device's text font size                Paint numPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
                ();
                (20f*factor);
                (Typeface.DEFAULT_BOLD);
                int textWidth=(int)(num, 0, ());

                (TAG, "text width:"+textWidth);

                //Draw the circle outside                //Paint outCirPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                //();
                //(iconSize - 15, 15, 15, outCirPaint);

                //Draw the inner circle                Paint inCirPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                ();
                (iconSize-15*factor, 15*factor, 15*factor, inCirPaint);

                //Draw numbers                (num, (float)(iconSize-textWidth/2-15*factor), 22*factor, numPaint);
            }
        }
        return numIcon;
    }

    /***
      *
      * Generate a picture with numbers (no border)
      * @param context
      * @param icon Image
      * @param isShowNum Do you want to draw numbers
      * @param num Number string: integer number exceeds 99, displayed as "99+"
      * @return
      */
    public static Bitmap generatorNumIcon2(Context context, Bitmap icon, boolean isShowNum, String num) {

        DisplayMetrics dm = ().getDisplayMetrics();
        //Basic screen density        float baseDensity = 1.5f;//240dpi
        float factor = /baseDensity;

        (TAG, "density:"+);
        (TAG, "dpi:"+);
        (TAG, "factor:"+factor);

        // Initialize the canvas        int iconSize = (int) ().getDimension(.app_icon_size);
        Bitmap numIcon = (iconSize, iconSize, Config.ARGB_8888);
        Canvas canvas = new Canvas(numIcon);

        // Copy the picture        Paint iconPaint = new Paint();
        (true);// Anti-shake        (true);// Used to filter Bitmap, so that when you choose Drawable, there will be an anti-aliasing effect        Rect src = new Rect(0, 0, (), ());
        Rect dst = new Rect(0, 0, iconSize, iconSize);
        (icon, src, dst, iconPaint);

        if(isShowNum){

            if((num)){
                num = "0";
            }

            if(!(num)){
                //Non-number                (TAG, "the num is not digit :"+ num);
                num = "0";
            }

            int numInt = (num);

            if(numInt > 99){//More than 99                num = "99+";
            }

            //Enable anti-aliasing and use the device's text font size            //Measure the width of text occupancy            Paint numPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
            ();
            (20f*factor);
            (Typeface.DEFAULT_BOLD);
            int textWidth=(int)(num, 0, ());
            (TAG, "text width:"+textWidth);

            /**----------------------------------*
              * TODO Draw rounded rectangle background start
              *-----------------------------------*/
            //Width of rounded rectangle background            int backgroundHeight = (int) (2*15*factor);
            int backgroundWidth = textWidth>backgroundHeight ? (int)(textWidth+10*factor) : backgroundHeight;

            ();//Save status
            ShapeDrawable drawable = getDefaultBackground(context);
            (backgroundHeight);
            (backgroundWidth);
            (0, 0, backgroundWidth, backgroundHeight);
            (iconSize-backgroundWidth, 0);
            (canvas);

            ();//Reset to the previously saved state
            /**----------------------------------*
              * TODO Draw rounded rectangle background end
              *-----------------------------------*/

            //Draw numbers            (num, (float)(iconSize-(backgroundWidth + textWidth)/2), 22*factor, numPaint);
        }
        return numIcon;
    }
    /***
      *
      * Generate a picture with numbers (with borders)
      * @param context
      * @param icon Image
      * @param isShowNum Do you want to draw numbers
      * @param num Number string: integer number exceeds 99, displayed as "99+"
      * @return
      */
    public static Bitmap generatorNumIcon3(Context context, Bitmap icon, boolean isShowNum, String num) {

        DisplayMetrics dm = ().getDisplayMetrics();
        //Basic screen density        float baseDensity = 1.5f;//240dpi
        float factor = /baseDensity;

        (TAG, "density:"+);
        (TAG, "dpi:"+);
        (TAG, "factor:"+factor);

        // Initialize the canvas        int iconSize = (int) ().getDimension(.app_icon_size);
        Bitmap numIcon = (iconSize, iconSize, Config.ARGB_8888);
        Canvas canvas = new Canvas(numIcon);

        // Copy the picture        Paint iconPaint = new Paint();
        (true);// Anti-shake        (true);// Used to filter Bitmap, so that when you choose Drawable, there will be an anti-aliasing effect        Rect src = new Rect(0, 0, (), ());
        Rect dst = new Rect(0, 0, iconSize, iconSize);
        (icon, src, dst, iconPaint);

        if(isShowNum){

            if((num)){
                num = "0";
            }

            if(!(num)){
                //Non-number                (TAG, "the num is not digit :"+ num);
                num = "0";
            }

            int numInt = (num);

            if(numInt > 99){//More than 99                num = "99+";
            }

            //Enable anti-aliasing and use the device's text font size            //Measure the width of text occupancy            Paint numPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
            ();
            (20f*factor);
            (Typeface.DEFAULT_BOLD);
            int textWidth=(int)(num, 0, ());
            (TAG, "text width:"+textWidth);

            /**----------------------------------*
              * TODO Draw the background of the rounded rectangle: first draw the border, then draw the inner rounded rectangle start
              *-----------------------------------*/
            //Width of rounded rectangle background            int backgroundHeight = (int) (2*15*factor);
            int backgroundWidth = textWidth>backgroundHeight ? (int)(textWidth+10*factor) : backgroundHeight;
            //The width of the border            int strokeThickness = (int) (2*factor);

            ();//Save status
            int strokeHeight = backgroundHeight + strokeThickness*2;
            int strokeWidth = textWidth>strokeHeight ? (int)(textWidth+ 10*factor + 2*strokeThickness) : strokeHeight;
            ShapeDrawable outStroke = getDefaultStrokeDrawable(context);
            (strokeHeight);
            (strokeWidth);
            (0, 0, strokeWidth, strokeHeight);
            (iconSize-strokeWidth-strokeThickness, strokeThickness);
            (canvas);

            ();//Reset to the previously saved state
            ();//Save status
            ShapeDrawable drawable = getDefaultBackground(context);
            ((int) (backgroundHeight+2*factor));
            ((int) (backgroundWidth+2*factor));
            (0, 0, backgroundWidth, backgroundHeight);
            (iconSize-backgroundWidth-2*strokeThickness, 2*strokeThickness);
            (canvas);

            ();//Reset to the previously saved state
            /**----------------------------------*
              * TODO Draw rounded rectangle background end
              *-----------------------------------*/

            //Draw numbers            (num, (float)(iconSize-(backgroundWidth + textWidth+4*strokeThickness)/2), (22)*factor+2*strokeThickness, numPaint);
        }
        return numIcon;
    }

    /***
      *
      * Generate a picture with numbers (with borders)
      * @param context
      * @param icon Image
      * @param isShowNum Do you want to draw numbers
      * @param num Number string: integer number exceeds 99, displayed as "99+"
      * @return
      */
    public static Bitmap generatorNumIcon4(Context context, Bitmap icon, boolean isShowNum, String num) {

        DisplayMetrics dm = ().getDisplayMetrics();
        //Basic screen density        float baseDensity = 1.5f;//240dpi
        float factor = /baseDensity;

        (TAG, "density:"+);
        (TAG, "dpi:"+);
        (TAG, "factor:"+factor);

        // Initialize the canvas        int iconSize = (int) ().getDimension(.app_icon_size);
        Bitmap numIcon = (iconSize, iconSize, Config.ARGB_8888);
        Canvas canvas = new Canvas(numIcon);

        // Copy the picture        Paint iconPaint = new Paint();
        (true);// Anti-shake treatment        (true);// Used to filter Bitmap, so that when you choose Drawable, there will be an anti-aliasing effect        Rect src = new Rect(0, 0, (), ());
        Rect dst = new Rect(0, 0, iconSize, iconSize);
        (icon, src, dst, iconPaint);

        if(isShowNum){

            if((num)){
                num = "0";
            }

            if(!(num)){
                //Non-number                (TAG, "the num is not digit :"+ num);
                num = "0";
            }

            int numInt = (num);

            if(numInt > 99){//More than 99                num = "99+";
            }

            //Enable anti-aliasing and use the device's text font            //Measure the width of text occupancy            Paint numPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
            ();
            (25f*factor);
            (Typeface.DEFAULT_BOLD);
            int textWidth=(int)(num, 0, ());
            (TAG, "text width:"+textWidth);

            /**----------------------------------*
              * TODO Draw rounded rectangle background start
              *-----------------------------------*/
            //The width of the border            int strokeThickness = (int) (DEFAULT_STROKE_WIDTH_DIP*factor);
            //Width of rounded rectangle background            float radiusPx = 15*factor;
            int backgroundHeight = (int) (2*(radiusPx+strokeThickness));//2*(radius + border width)            int backgroundWidth = textWidth>backgroundHeight ? (int)(textWidth + 10*factor + 2*strokeThickness) : backgroundHeight;

            ();//Save status
            ShapeDrawable drawable = getDefaultBackground2(context);
            (backgroundHeight);
            (backgroundWidth);
            (0, 0, backgroundWidth, backgroundHeight);
            (iconSize-backgroundWidth-strokeThickness, 2*strokeThickness);
            (canvas);

            ();//Reset to the previously saved state
            /**----------------------------------*
              * TODO Draw rounded rectangle background end
              *-----------------------------------*/

            //Draw numbers            (num, (float)(iconSize-(backgroundWidth + textWidth+2*strokeThickness)/2), (float) (25*factor+2.5*strokeThickness), numPaint);
        }
        return numIcon;
    }

    /***
      * Shortcuts to create native systems
      * @param context
      * @param clazz started activity
      * @param isShowNum Whether to display numbers
      * @param num Number displayed: integer
      * @param isStroke Whether to add borders
      */

    public static void installRawShortCut(Context context, Class<?> clazz, boolean isShowNum, String num, boolean isStroke) {
        (TAG, "installShortCut....");

        Intent shortcutIntent = new Intent(    ".INSTALL_SHORTCUT");
        //name        (Intent.EXTRA_SHORTCUT_NAME,    (.app_name));

        // Is it possible to have multiple copies of shortcuts? If the parameter is true, multiple shortcuts can be generated. If it is false, it will not be added repeatedly        ("duplicate", false);

        //Click the shortcut: Open activity        Intent mainIntent = new Intent(Intent.ACTION_MAIN);
        (Intent.CATEGORY_LAUNCHER);
        (context, clazz);
        (Intent.EXTRA_SHORTCUT_INTENT, mainIntent);

        //Shortcut Icon        if(isStroke){
            (Intent.EXTRA_SHORTCUT_ICON,
                    generatorNumIcon4(
                            context, 
                            ((BitmapDrawable)().getDrawable(.ic_launcher)).getBitmap(),
                            isShowNum, 
                            num));
        }else{
            (Intent.EXTRA_SHORTCUT_ICON,
                    generatorNumIcon2(
                            context, 
                            ((BitmapDrawable)().getDrawable(.ic_launcher)).getBitmap(),
                            isShowNum, 
                            num));
        }
        (shortcutIntent);
    }

    /***
      * Have you created a shortcut?
      * @param context
      * @return
      */
    public static boolean isAddShortCut(Context context) {
         (TAG, "isAddShortCut....");

      boolean isInstallShortcut = false;
      final ContentResolver cr = ();

      //TODO commented code, on some mobile phones: the ROM system has been modified, but cannot support it      /*int versionLevel = .SDK_INT;
             String AUTHORITY = ".";
             //The file names of systems above 2.2 are different
             if (versionLevel >= 8) {
               AUTHORITY = ".";
             } else {
               AUTHORITY = "";
             }*/

        String AUTHORITY = getAuthorityFromPermission(context, ".READ_SETTINGS");
        (TAG, "AUTHORITY : " +AUTHORITY);
        final Uri CONTENT_URI = ("content://" + AUTHORITY
        + "/favorites?notify=true");

        Cursor c = (CONTENT_URI,
            new String[] { "title" }, "title=?",
            new String[] { (.app_name) }, null);

        if (c != null && () > 0) {
          isInstallShortcut = true;
        }

        if(c != null){
            ();
        }

        (TAG, "isAddShortCut....isInstallShortcut="+isInstallShortcut);

      return isInstallShortcut;
    }

    /**
      * Delete shortcuts
      * @param context
      * @param clazz
      */
     public static void deleteShortCut(Context context, Class<?> clazz){
         (TAG, "delShortcut....");

         if (("Xiaomi")){
            //Millet            //When it is "", the number is not displayed, which is equivalent to hiding it)            xiaoMiShortCut(context, clazz, "");

        }else if(("samsung")){
            //Samsung            samsungShortCut(context, "0");

        }else {//Other native system mobile phones            //Delete the shortcut to display numbers            deleteRawShortCut(context, clazz);
            //Installing a shortcut that does not display numbers            //installRawShortCut(context, clazz, false, "0");
        }
     }

    /***
      * Shortcuts to delete native system
      * @param context
      * @param clazz started activity
      */
    public static void deleteRawShortCut(Context context, Class<?> clazz) {
        Intent intent = new Intent(".UNINSTALL_SHORTCUT");
        //The name of the shortcut        (Intent.EXTRA_SHORTCUT_NAME, (.app_name));

        Intent intent2 = new Intent(); 
        (context, clazz); 
        (Intent.ACTION_MAIN); 
        (Intent.CATEGORY_LAUNCHER); 
        (Intent.EXTRA_SHORTCUT_INTENT,intent2); 

        (intent);
    }

     /***
      * Obtain the corresponding authentication URI
      * @param context
      * @param permission
      * @return
      */
    public static String getAuthorityFromPermission(Context context, String permission) {
        if ((permission)) {
            return null;
        }
        List<PackageInfo> packInfos = ().getInstalledPackages(PackageManager.GET_PROVIDERS);
        if (packInfos == null) {
            return null;
        }
        for (PackageInfo info : packInfos) {
            ProviderInfo[] providers = ;
            if (providers != null) {
                for (ProviderInfo provider : providers) {
                    if (()
                            || ()) {
                        return ;
                    }
                }
            }
        }
        return null;
    }

    /***
      * Add numbers to the shortcut of Xiaomi application icon<br>
      *
      *
      * @param context
      * @param num The number displayed: greater than 99, is "99". When "", the number is not displayed, which is equivalent to hidden)<br><br>
      *
      * Note:
      * ()+"/."+() (This is the path to start the activity) "/." cannot be missing.
      *
      */
    public static void xiaoMiShortCut(Context context,Class&lt;?&gt; clazz, String num)
     {
        (TAG, "xiaoMiShortCut....");
        Intent localIntent = new Intent(".APPLICATION_MESSAGE_UPDATE");
        (".update_application_component_name", ()+"/."+());
        if((num)){
            num = "";
        }else{
          int numInt = (num);
          if (numInt &gt; 0){
             if (numInt &gt; 99){
                num = "99";
           }
          }else{
              num = "0";
          }
        }
        (".update_application_message_text", num);
        (localIntent);
     }                                            

     /***
      * Sony phone: Add numbers to the shortcut to the app icon
      * @param context
      * @param num
      */
    public static void sonyShortCut(Context context, String num)
     {
      String activityName = getLaunchActivityName(context);
      if (activityName == null){
       return;
      }
      Intent localIntent = new Intent();
      int numInt = (num);
      boolean isShow = true;
      if (numInt &lt; 1){
       num = "";
       isShow = false;
      }else if (numInt &gt; 99){
          num = "99";
      }
      (".SHOW_MESSAGE", isShow);
      (".UPDATE_BADGE");
      (".ACTIVITY_NAME", activityName);
      ("", num);
      (".PACKAGE_NAME", ());
      (localIntent);
     }

     /***
      * Samsung phone: Add numbers to the shortcut to the application icon
      * @param context
      * @param num
      */
    public static void samsungShortCut(Context context, String num)
     {
        int numInt = (num);
      if (numInt &lt; 1)
      {
       num = "0";
      }else if (numInt &gt; 99){
          num = "99";
      }
         String activityName = getLaunchActivityName(context);
      Intent localIntent = new Intent(".BADGE_COUNT_UPDATE");
      ("badge_count", num);
      ("badge_count_package_name", ());
      ("badge_count_class_name", activityName);
      (localIntent);
     }

     /***
      * Add numbers to the shortcut to the application icon
      * @param clazz started activity
      * @param isShowNum Whether to display numbers
      * @param num Number displayed: integer
      * @param isStroke Whether to add borders
      *
      */
    public static void addNumShortCut(Context context,Class&lt;?&gt; clazz,boolean isShowNum, String num, boolean isStroke)
     {
         (TAG, "manufacturer="+);
      if (("Xiaomi")){
          //Millet       xiaoMiShortCut(context, clazz, num);

      }else if(("samsung")){
          //Samsung          samsungShortCut(context, num);

      }else {//Other native system mobile phones          installRawShortCut(context, , isShowNum, num, isStroke);
      }

     }

     /***
      * Get the name of the startup activity of the current application:
      android:name:" configured in *
      * @param context
      * @return
      */
    public static String getLaunchActivityName(Context context)
     {
      PackageManager localPackageManager = ();
      Intent localIntent = new Intent("");
      ("");
      try
      {
       Iterator&lt;ResolveInfo&gt; localIterator = (localIntent, 0).iterator();
       while (())
       {
        ResolveInfo localResolveInfo = ();
        if (!(()))
         continue;
        String str = ;
        return str;
       }
      }
      catch (Exception localException)
      {
       return null;
      }
      return null;
     }

    /***
      * Get a default background: rounded rectangle<br><br>
      * Use code to generate a background: equivalent to a background with <shape>xml
      *
      * @return
      */
    private static ShapeDrawable getDefaultBackground(Context context) {

        //This is to deal with mobile phones with different resolutions, screen compatibility        int r = dipToPixels(context,DEFAULT_CORNER_RADIUS_DIP);
        float[] outerR = new float[] {r, r, r, r, r, r, r, r};

        //Round rectangle        RoundRectShape rr = new RoundRectShape(outerR, null, null);
        ShapeDrawable drawable = new ShapeDrawable(rr);
        ().setColor(DEFAULT_NUM_COLOR);//Set the color        return drawable;

    }
    /***
      * Get a default background: rounded rectangle<br><br>
      * Use code to generate a background: equivalent to a background with <shape>xml
      *
      * @return
      */
    private static ShapeDrawable getDefaultBackground2(Context context) {

        //This is to deal with mobile phones with different resolutions, screen compatibility        int r = dipToPixels(context,DEFAULT_CORNER_RADIUS_DIP);
        float[] outerR = new float[] {r, r, r, r, r, r, r, r};
        int distance = dipToPixels(context,DEFAULT_STROKE_WIDTH_DIP);

        //Round rectangle        RoundRectShape rr = new RoundRectShape(outerR, null, null);
        customBorderDrawable drawable = new customBorderDrawable(context,rr);
        ().setColor(DEFAULT_NUM_COLOR);//Set fill color        ().setColor(DEFAULT_STROKE_COLOR);//Set border color        ().setStrokeWidth(distance);//Set the border width        return drawable;

    }

    /***
      * Get a default background: rounded rectangle<br><br>
      * Use code to generate a background: equivalent to a background with <shape>xml
      *
      * @return
      */
    private static ShapeDrawable getDefaultStrokeDrawable(Context context) {

        //This is to deal with mobile phones with different resolutions, screen compatibility        int r = dipToPixels(context, DEFAULT_CORNER_RADIUS_DIP);
        int distance = dipToPixels(context, DEFAULT_STROKE_WIDTH_DIP);
        float[] outerR = new float[] {r, r, r, r, r, r, r, r};

        //Round rectangle        RoundRectShape rr = new RoundRectShape(outerR, null, null);
        ShapeDrawable drawable = new ShapeDrawable(rr);
        ().setStrokeWidth(distance);
        ().setStyle();
        ().setColor(DEFAULT_STROKE_COLOR);//Set the color        return drawable;
    }
    /***
     * dp to px
     * @param dip
     * @return
     */
    public static int dipToPixels(Context context, int dip) {
        Resources r = ();
        float px = (TypedValue.COMPLEX_UNIT_DIP, dip, ());
        return (int) px;
    }
}

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!