Exemplo n.º 1
0
  private void init(Context context, AttributeSet attributeSet) {
    mButtonSpacing =
        (int)
            (getResources().getDimension(R.dimen.fab_actions_spacing)
                - getResources().getDimension(R.dimen.fab_shadow_radius)
                - getResources().getDimension(R.dimen.fab_shadow_offset));
    mLabelsMargin = getResources().getDimensionPixelSize(R.dimen.fab_labels_margin);
    mLabelsVerticalOffset = getResources().getDimensionPixelSize(R.dimen.fab_shadow_offset);

    TypedArray attr =
        context.obtainStyledAttributes(attributeSet, R.styleable.FloatingActionsMenu, 0, 0);
    mAddButtonPlusColor =
        attr.getColor(
            R.styleable.FloatingActionsMenu_fab_addButtonPlusIconColor,
            getColor(android.R.color.white));
    mAddButtonColorNormal =
        attr.getColor(
            R.styleable.FloatingActionsMenu_fab_addButtonColorNormal,
            getColor(android.R.color.holo_blue_dark));
    mAddButtonColorPressed =
        attr.getColor(
            R.styleable.FloatingActionsMenu_fab_addButtonColorPressed,
            getColor(android.R.color.holo_blue_light));
    mExpandDirection = attr.getInt(R.styleable.FloatingActionsMenu_fab_expandDirection, EXPAND_UP);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionsMenu_fab_labelStyle, 0);
    attr.recycle();

    if (mLabelsStyle != 0 && expandsHorizontally()) {
      throw new IllegalStateException(
          "Action labels in horizontal expand orientation is not supported.");
    }

    createAddButton(context);
  }