private void init(Context context, AttributeSet attributeSet) {
    TypedArray attr = getTypedArray(context, attributeSet, R.styleable.MaterialMenuView);

    try {
      int color = attr.getColor(R.styleable.MaterialMenuView_mm_color, DEFAULT_COLOR);
      int scale = attr.getInteger(R.styleable.MaterialMenuView_mm_scale, DEFAULT_SCALE);
      int transformDuration =
          attr.getInteger(
              R.styleable.MaterialMenuView_mm_transformDuration, DEFAULT_TRANSFORM_DURATION);
      int pressedDuration =
          attr.getInteger(
              R.styleable.MaterialMenuView_mm_pressedDuration, DEFAULT_PRESSED_DURATION);
      MaterialMenuDrawable.Stroke stroke =
          MaterialMenuDrawable.Stroke.valueOf(
              attr.getInteger(R.styleable.MaterialMenuView_mm_strokeWidth, 0));
      boolean rtlEnabled = attr.getBoolean(R.styleable.MaterialMenuView_mm_rtlEnabled, false);

      drawable =
          new MaterialMenuDrawable(
              context, color, stroke, scale, transformDuration, pressedDuration);
      drawable.setRTLEnabled(rtlEnabled);
    } finally {
      attr.recycle();
    }

    drawable.setCallback(this);
  }
 private void adjustDrawablePadding() {
   if (drawable != null) {
     drawable.setBounds(
         0,
         0,
         drawable.getIntrinsicWidth() + getPaddingLeft() + getPaddingRight(),
         drawable.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom());
   }
 }
 @Override
 public void draw(Canvas canvas) {
   super.draw(canvas);
   if (getPaddingLeft() != 0 || getPaddingTop() != 0) {
     int saveCount = canvas.getSaveCount();
     canvas.save();
     canvas.translate(getPaddingLeft(), getPaddingTop());
     drawable.draw(canvas);
     canvas.restoreToCount(saveCount);
   } else {
     drawable.draw(canvas);
   }
 }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int paddingX = getPaddingLeft() + getPaddingRight();
    int paddingY = getPaddingTop() + getPaddingBottom();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      widthMeasureSpec =
          MeasureSpec.makeMeasureSpec(drawable.getIntrinsicWidth() + paddingX, MeasureSpec.EXACTLY);
      heightMeasureSpec =
          MeasureSpec.makeMeasureSpec(
              drawable.getIntrinsicHeight() + paddingY, MeasureSpec.EXACTLY);
      setMeasuredDimension(widthMeasureSpec, heightMeasureSpec);
    } else {
      setMeasuredDimension(
          drawable.getIntrinsicWidth() + paddingX, drawable.getIntrinsicHeight() + paddingY);
    }
  }
 @Override
 public void setTransformationOffset(
     MaterialMenuDrawable.AnimationState animationState, float value) {
   currentState = drawable.setTransformationOffset(animationState, value);
 }
 @Override
 public void setInterpolator(Interpolator interpolator) {
   drawable.setInterpolator(interpolator);
 }
 @Override
 public void setRTLEnabled(boolean rtlEnabled) {
   drawable.setRTLEnabled(rtlEnabled);
 }
 @Override
 public void setTransformationDuration(int duration) {
   drawable.setTransformationDuration(duration);
 }
 @Override
 public void setPressedDuration(int duration) {
   drawable.setPressedDuration(duration);
 }
示例#10
0
 @Override
 public void setColor(int color) {
   drawable.setColor(color);
 }
示例#11
0
 @Override
 public void animatePressedState(MaterialMenuDrawable.IconState state) {
   currentState = state;
   drawable.animateIconState(state, true);
 }
示例#12
0
 @Override
 public void animateState(MaterialMenuDrawable.IconState state) {
   currentState = state;
   drawable.animateIconState(state, false);
 }
示例#13
0
 @Override
 public MaterialMenuDrawable.IconState getState() {
   return drawable.getIconState();
 }
示例#14
0
 @Override
 public void setState(MaterialMenuDrawable.IconState state) {
   currentState = state;
   drawable.setIconState(state);
 }