Пример #1
0
  @Override
  public void init(Context context, AttributeSet attrs, int defStyle) {
    super.init(context, attrs, defStyle);
    borderWidth = 0;
    if (attrs != null) {
      TypedArray typedArray =
          context.obtainStyledAttributes(attrs, R.styleable.ShaderImageView, defStyle, 0);
      triangleHeightPx =
          typedArray.getDimensionPixelSize(R.styleable.ShaderImageView_siTriangleHeight, 0);
      int arrowPositionInt =
          typedArray.getInt(
              R.styleable.ShaderImageView_siArrowPosition, ArrowPosition.LEFT.ordinal());
      arrowPosition = ArrowPosition.values()[arrowPositionInt];
      typedArray.recycle();
    }

    if (triangleHeightPx == 0) {
      triangleHeightPx = dpToPx(context.getResources().getDisplayMetrics(), DEFAULT_HEIGHT_DP);
    }
  }