Пример #1
0
  private void fab() {
    RapidFloatingActionContentLabelList rfaContent =
        new RapidFloatingActionContentLabelList(context);
    rfaContent.setOnRapidFloatingActionContentLabelListListener(this);
    List<RFACLabelItem> items = new ArrayList<>();
    items.add(
        new RFACLabelItem<Integer>()
            .setLabel("求救")
            .setResId(R.mipmap.ic_launcher)
            .setIconNormalColor(0xffd84315)
            .setIconPressedColor(0xffbf360c)
            .setWrapper(0));
    items.add(
        new RFACLabelItem<Integer>()
            .setLabel("求助")
            //                        .setResId(R.mipmap.ico_test_c)
            .setDrawable(getResources().getDrawable(R.mipmap.ic_launcher))
            .setIconNormalColor(0xff4e342e)
            .setIconPressedColor(0xff3e2723)
            .setLabelColor(Color.WHITE)
            .setLabelSizeSp(14)
            .setLabelBackgroundDrawable(
                ABShape.generateCornerShapeDrawable(0xaa000000, ABTextUtil.dip2px(context, 4)))
            .setWrapper(1));
    items.add(
        new RFACLabelItem<Integer>()
            .setLabel("提问")
            .setResId(R.mipmap.ic_launcher)
            .setIconNormalColor(0xff056f00)
            .setIconPressedColor(0xff0d5302)
            .setLabelColor(0xff056f00)
            .setWrapper(2));
    rfaContent
        .setItems(items)
        .setIconShadowRadius(ABTextUtil.dip2px(context, 5))
        .setIconShadowColor(0xff888888)
        .setIconShadowDy(ABTextUtil.dip2px(context, 5));

    rfabHelper = new RapidFloatingActionHelper(context, rfaLayout, rfaButton, rfaContent).build();
  }
 /**
  * 根据移动的距离来刷新原来的圆半径大小
  *
  * @param distance
  */
 private void refreshCurRadiusByMoveDistance(int distance) {
   if (distance > maxMoveLength) {
     isArrivedMaxMoved = true;
     curRadius = 0;
   } else {
     isArrivedMaxMoved = false;
     float calcRadius = (1 - 1f * distance / maxMoveLength) * originRadius;
     float maxRadius = ABTextUtil.dip2px(context, 2);
     curRadius = (int) Math.max(calcRadius, maxRadius);
     //            Logger.d(TAG, "[refreshCurRadiusByMoveDistance]curRadius: " + curRadius + ",
     // calcRadius: " + calcRadius + ", maxRadius: " + maxRadius);
   }
 }
  private void init(Context context) {
    this.context = context;

    setBackgroundColor(Color.TRANSPARENT);

    // 设置绘制flag的paint
    paint = new Paint();
    paint.setColor(patientColor);
    paint.setAntiAlias(true);

    // 设置绘制文字的paint
    textPaint = new TextPaint();
    textPaint.setAntiAlias(true);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(ABTextUtil.sp2px(context, 12));
    textPaint.setTextAlign(Paint.Align.CENTER);
    textFontMetrics = textPaint.getFontMetrics();
  }