code: public void setBorder(int flag, int size, int color) {
          if (mBorder != flag || mBorderSize != size || mBorderColor != color) {
              mBorder = flag;
              mBorderSize = size;
              mBorderColor = color;
  
              if (flag <= 0) {
                  mBorderDrawable = null;
              } else {
                  RectF borderRect;
                  if ((flag & BORDER_ALL) == BORDER_ALL)
                      borderRect = new RectF(size, size, size, size);
                  else {
                      int l = 0, t = 0, r = 0, b = 0;
  
                      if ((flag & BORDER_LEFT) == BORDER_LEFT)
                          l = size;
                      if ((flag & BORDER_RIGHT) == BORDER_RIGHT)
                          r = size;
                      if ((flag & BORDER_TOP) == BORDER_TOP)
                          t = size;
                      if ((flag & BORDER_BOTTOM) == BORDER_BOTTOM)
                          b = size;
  
                      borderRect = new RectF(l, t, r, b);
                  }
  
                  if (mBorderDrawable == null) {
                      ShapeDrawable drawable = new ShapeDrawable(new BorderShape(borderRect));
                      Paint paint = drawable.getPaint();
                      paint.setColor(color);
                      drawable.setCallback(this);
                      mBorderDrawable = drawable;
                  } else {
                      ShapeDrawable drawable = (ShapeDrawable) mBorderDrawable;
                      Paint paint = drawable.getPaint();
                      paint.setColor(color);
                      BorderShape shape = (BorderShape) drawable.getShape();
                      shape.setBorder(borderRect);
                  }
              }
  
              invalidate();
          }
      }
docs: Set the border, You can init border size, color and decision that direction contains border
  
  @param flag  use {@link #BORDER_ALL } if you need All border,
  or {@link #BORDER_LEFT} the view will have Left border
  of case you can use eg: {@link #BORDER_LEFT}|{@link #BORDER_BOTTOM}
  the view will left and bottom border
  <p>
  if you not use border you need set the flag to 0
  @param size  set all border size, unit is px, if you use dp, plx see {@link Ui#dipToPx(Resources, float)} )}
  @param color set all border color