Example #1
0
  private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LSystemView);

    // Instantiate Display
    String className = typedArray.getString(R.styleable.LSystemView_ls_display_class);
    if (!TextUtils.isEmpty(className)) {
      try {
        mDisplay = (Display) Class.forName(className).newInstance();
      } catch (Exception e) {
        Log.e(TAG, "", e);
      }
    }

    /* Display properties */
    if (mDisplay != null) {
      mDisplay.setDirection(
          typedArray.getFloat(R.styleable.LSystemView_ls_direction, mDisplay.getDirection()));
      mDisplay.setAngle(typedArray.getFloat(R.styleable.LSystemView_ls_angle, mDisplay.getAngle()));
      mDisplay.setStep(typedArray.getFloat(R.styleable.LSystemView_ls_step, mDisplay.getStep()));
      mDisplay.setIterations(
          typedArray.getInteger(R.styleable.LSystemView_ls_iterations, mDisplay.getIterations()));
      mDisplay.setPercentX(
          typedArray.getFraction(
              R.styleable.LSystemView_ls_position_x, 1, 1, mDisplay.getPercentX()));
      mDisplay.setPercentY(
          typedArray.getFraction(
              R.styleable.LSystemView_ls_position_y, 1, 1, mDisplay.getPercentY()));
      mDisplay.setColor(
          typedArray.getColor(R.styleable.LSystemView_ls_paint_color, mDisplay.getColor()));
    }

    typedArray.recycle();
  }
  private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray typedArray =
        context.obtainStyledAttributes(attrs, R.styleable.IncreasingSeekBar, defStyle, 0);
    try {
      mOrientation =
          Orientation.fromId(
              typedArray.getInt(
                  R.styleable.IncreasingSeekBar_isb_orientation, Orientation.HORIZONTAL.id));
      mMaxRang = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_max, DEF_MAX_RANG);
      mCurrValue = typedArray.getInt(R.styleable.IncreasingSeekBar_isb_curr_value, 0);
      mGapWidthPercent =
          typedArray.getFraction(
              R.styleable.IncreasingSeekBar_isb_gap_percent, 1, 1, DEF_GAP_PERCENT);
      mAllowUserTouch =
          typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_allow_user_touch, true);
      mDrawBorder = typedArray.getBoolean(R.styleable.IncreasingSeekBar_isb_draw_border, false);
      mBorderColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_border_color, DEF_COLOR);
      mBorderWidth =
          typedArray.getDimension(R.styleable.IncreasingSeekBar_isb_border_width, DEF_BORDER_WIDTH);
      mMainColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color, DEF_COLOR);
      mStartColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_start, -1);
      mEndColor = typedArray.getColor(R.styleable.IncreasingSeekBar_isb_color_end, -1);

    } finally {
      typedArray.recycle();
    }

    mBarItemPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBarItemPaint.setColor(mMainColor);
    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setStrokeWidth(mBorderWidth);
    mBarItemPaint.setColor(mBorderColor);
  }
 static int getDimensionOrFraction(TypedArray a, int index, int base, int defValue) {
   TypedValue value = a.peekValue(index);
   if (value == null) return defValue;
   if (value.type == TypedValue.TYPE_DIMENSION) {
     return a.getDimensionPixelOffset(index, defValue);
   } else if (value.type == TypedValue.TYPE_FRACTION) {
     // Round it to avoid values like 47.9999 from getting truncated
     return Math.round(a.getFraction(index, base, base, defValue));
   }
   return defValue;
 }
Example #4
0
  public Panel(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Panel);
    mDuration =
        a.getInteger(R.styleable.Panel_animationDuration, 750); // duration defaults to 750 ms
    mPosition = a.getInteger(R.styleable.Panel_position, BOTTOM); // position defaults to BOTTOM
    mLinearFlying =
        a.getBoolean(R.styleable.Panel_linearFlying, false); // linearFlying defaults to false
    mWeight = a.getFraction(R.styleable.Panel_weight, 0, 1, 0.0f); // weight defaults to 0.0
    if (mWeight < 0 || mWeight > 1) {
      mWeight = 0.0f;
      Log.w(TAG, a.getPositionDescription() + ": weight must be > 0 and <= 1");
    }
    mOpenedHandle = a.getDrawable(R.styleable.Panel_openedHandle);
    mClosedHandle = a.getDrawable(R.styleable.Panel_closedHandle);

    RuntimeException e = null;
    mHandleId = a.getResourceId(R.styleable.Panel_handle, 0);
    if (mHandleId == 0) {
      e =
          new IllegalArgumentException(
              a.getPositionDescription()
                  + ": The handle attribute is required and must refer to a valid child.");
    }
    mContentId = a.getResourceId(R.styleable.Panel_content, 0);
    if (mContentId == 0) {
      e =
          new IllegalArgumentException(
              a.getPositionDescription()
                  + ": The content attribute is required and must refer to a valid child.");
    }
    a.recycle();

    if (e != null) {
      throw e;
    }
    mOrientation = (mPosition == TOP || mPosition == BOTTOM) ? VERTICAL : HORIZONTAL;
    setOrientation(mOrientation);
    mState = State.READY;
    mGestureListener = new PanelOnGestureListener();
    mGestureDetector = new GestureDetector(mGestureListener);
    mGestureDetector.setIsLongpressEnabled(false);

    // i DON'T really know why i need this...
    setBaselineAligned(false);
  }
  /**
   * 介绍TypedArray使用方法 获取 attr中formate 十种类型属性值
   * float,integer,boolean,fraction,string,dimension,color,reference,enum,flag
   *
   * <p>
   *
   * @param context 上下文环境
   * @param attrs 属性集合
   */
  private void printAttributes(Context context, AttributeSet attrs) {
    TypedArray typedArray =
        context.obtainStyledAttributes(attrs, R.styleable.CustomTextViewStyle, 0, 0);
    System.out.println(
        "typedArray.getChangingConfigurations() = "
            + Integer.toHexString(typedArray.getChangingConfigurations()));
    float float_value = typedArray.getFloat(R.styleable.CustomTextViewStyle_float_value, 0f);
    int integer_value = typedArray.getInteger(R.styleable.CustomTextViewStyle_integer_value, 0);
    boolean boolean_value =
        typedArray.getBoolean(R.styleable.CustomTextViewStyle_boolean_value, false);

    // public float getFraction (int index, int base, int pbase, float defValue)
    // 如果值为10% 则 fraction_value=10%*base
    // 如果值格式为10%p,则fraction_value=10%*pbase
    float fraction_value =
        typedArray.getFraction(R.styleable.CustomTextViewStyle_fraction_value, 1, 1, 0);
    String string_value = typedArray.getString(R.styleable.CustomTextViewStyle_string_value);

    // 获取像素值,浮点数  eg:27.5625
    float dimension_value_float =
        typedArray.getDimension(R.styleable.CustomTextViewStyle_dimension_value, 0f);
    // 将取得浮点像素值四舍五入 eg:28
    int dimension_value =
        typedArray.getDimensionPixelSize(R.styleable.CustomTextViewStyle_dimension_value, 0);
    // 将取得浮点像素值直接截取整数部分 eg:27
    int dimension_value_offset_ =
        typedArray.getDimensionPixelOffset(R.styleable.CustomTextViewStyle_dimension_value, 0);

    int color_value = typedArray.getColor(R.styleable.CustomTextViewStyle_color_value, 0);
    int reference_drawable_value =
        typedArray.getResourceId(R.styleable.CustomTextViewStyle_reference_drawable_value, 0);
    int reference_array_value =
        typedArray.getResourceId(R.styleable.CustomTextViewStyle_reference_array_value, 0);
    int enum_value = typedArray.getInt(R.styleable.CustomTextViewStyle_enum_value, -1);
    int flag_value = typedArray.getInt(R.styleable.CustomTextViewStyle_flag_value, -1);

    System.out.println(
        "float_value = ["
            + float_value
            + "], integer_value = ["
            + integer_value
            + "], "
            + "boolean_value = ["
            + boolean_value
            + "], fraction_value = ["
            + fraction_value
            + "], string_value = ["
            + string_value
            + "], dimension_value = ["
            + dimension_value
            + "], color_value = ["
            + color_value
            + "], "
            + "reference_drawable_value ="
            + " [0x"
            + Integer.toHexString(reference_drawable_value)
            + "], enum_value = ["
            + enum_value
            + "], "
            + "flag_value1 = ["
            + flag_value
            + "]");

    // 后期数据处理,设置左边图片
    Drawable drawable;
    drawable = typedArray.getDrawable(R.styleable.CustomTextViewStyle_reference_drawable_value);
    // or
    drawable = context.getDrawable(reference_drawable_value);
    drawable.setBounds(new Rect(0, 0, 50, 50));
    setCompoundDrawables(drawable, null, null, null);
    // 设置文字是否大写,斜体
    if (flag_value >= 0) {
      Typeface typeface = getTypeface();
      setTypeface(Typeface.defaultFromStyle(flag_value));
    }

    // 其他方法getTextArray
    CharSequence[] arrays;
    arrays = typedArray.getTextArray(R.styleable.CustomTextViewStyle_reference_array_value);
    // or
    arrays = context.getResources().getTextArray(reference_array_value);
    for (int i = 0; i < arrays.length; i++) {
      System.out.println("arrays[" + i + "] = " + arrays[i]);
    }

    // 遍历TypedArray
    for (int i = 0, m = typedArray.getIndexCount(); i < m; i++) {
      System.out.println(
          "typedArray"
              + i
              + " type= "
              + typedArray.getType(i)
              + " value="
              + typedArray.getString(i));
    }

    int textsize = typedArray.getDimensionPixelSize(R.styleable.CustomTextViewStyle_text_size, 10);
    int textcolor = typedArray.getColor(R.styleable.CustomTextViewStyle_text_color, Color.BLACK);
    String text = typedArray.getString(R.styleable.CustomTextViewStyle_text_content);
    int padding = typedArray.getDimensionPixelSize(R.styleable.CustomTextViewStyle_padding, 0);

    setTextColor(textcolor);
    setTextSize(textsize);
    setText(text);
    setPadding(padding, padding, padding, padding);

    typedArray.recycle();
  }
  private void parseKeyboardAttributes(final XmlPullParser parser) {
    final AttributeSet attr = Xml.asAttributeSet(parser);
    final TypedArray keyboardAttr =
        mContext.obtainStyledAttributes(
            attr, R.styleable.Keyboard, R.attr.keyboardStyle, R.style.Keyboard);
    final TypedArray keyAttr = mResources.obtainAttributes(attr, R.styleable.Keyboard_Key);
    try {
      final KeyboardParams params = mParams;
      final int height = params.mId.mHeight;
      final int width = params.mId.mWidth;
      params.mOccupiedHeight = height;
      params.mOccupiedWidth = width;
      params.mTopPadding =
          (int)
              keyboardAttr.getFraction(R.styleable.Keyboard_keyboardTopPadding, height, height, 0);
      params.mBottomPadding =
          (int)
              keyboardAttr.getFraction(
                  R.styleable.Keyboard_keyboardBottomPadding, height, height, 0);
      params.mLeftPadding =
          (int) keyboardAttr.getFraction(R.styleable.Keyboard_keyboardLeftPadding, width, width, 0);
      params.mRightPadding =
          (int)
              keyboardAttr.getFraction(R.styleable.Keyboard_keyboardRightPadding, width, width, 0);

      final int baseWidth = params.mOccupiedWidth - params.mLeftPadding - params.mRightPadding;
      params.mBaseWidth = baseWidth;
      params.mDefaultKeyWidth =
          (int)
              keyAttr.getFraction(
                  R.styleable.Keyboard_Key_keyWidth,
                  baseWidth,
                  baseWidth,
                  baseWidth / DEFAULT_KEYBOARD_COLUMNS);
      params.mHorizontalGap =
          (int)
              keyboardAttr.getFraction(R.styleable.Keyboard_horizontalGap, baseWidth, baseWidth, 0);
      // TODO: Fix keyboard geometry calculation clearer. Historically vertical gap between
      // rows are determined based on the entire keyboard height including top and bottom
      // paddings.
      params.mVerticalGap =
          (int) keyboardAttr.getFraction(R.styleable.Keyboard_verticalGap, height, height, 0);
      final int baseHeight =
          params.mOccupiedHeight - params.mTopPadding - params.mBottomPadding + params.mVerticalGap;
      params.mBaseHeight = baseHeight;
      params.mDefaultRowHeight =
          (int)
              ResourceUtils.getDimensionOrFraction(
                  keyboardAttr,
                  R.styleable.Keyboard_rowHeight,
                  baseHeight,
                  baseHeight / DEFAULT_KEYBOARD_ROWS);

      params.mKeyVisualAttributes = KeyVisualAttributes.newInstance(keyAttr);

      params.mMoreKeysTemplate =
          keyboardAttr.getResourceId(R.styleable.Keyboard_moreKeysTemplate, 0);
      params.mMaxMoreKeysKeyboardColumn =
          keyAttr.getInt(R.styleable.Keyboard_Key_maxMoreKeysColumn, 5);

      params.mThemeId = keyboardAttr.getInt(R.styleable.Keyboard_themeId, 0);
      params.mIconsSet.loadIcons(keyboardAttr);
      final String language = params.mId.mLocale.getLanguage();
      params.mCodesSet.setLanguage(language);
      params.mTextsSet.setLanguage(language);
      final RunInLocale<Void> job =
          new RunInLocale<Void>() {
            @Override
            protected Void job(final Resources res) {
              params.mTextsSet.loadStringResources(mContext);
              return null;
            }
          };
      // Null means the current system locale.
      final Locale locale =
          SubtypeLocaleUtils.isNoLanguage(params.mId.mSubtype) ? null : params.mId.mLocale;
      job.runInLocale(mResources, locale);

      final int resourceId =
          keyboardAttr.getResourceId(R.styleable.Keyboard_touchPositionCorrectionData, 0);
      if (resourceId != 0) {
        final String[] data = mResources.getStringArray(resourceId);
        params.mTouchPositionCorrection.load(data);
      }
    } finally {
      keyAttr.recycle();
      keyboardAttr.recycle();
    }
  }
  public static PercentLayoutHelper.PercentLayoutInfo getPercentLayoutInfo(
      Context context, AttributeSet attrs) {
    PercentLayoutHelper.PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, styleable.PercentLayout_Layout);
    float value =
        array.getFraction(styleable.PercentLayout_Layout_layout_widthPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent width: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.widthPercent = value;
    }

    value = array.getFraction(styleable.PercentLayout_Layout_layout_heightPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent height: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.heightPercent = value;
    }

    value = array.getFraction(styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.leftMarginPercent = value;
      info.topMarginPercent = value;
      info.rightMarginPercent = value;
      info.bottomMarginPercent = value;
    }

    value = array.getFraction(styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent left margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.leftMarginPercent = value;
    }

    value = array.getFraction(styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent top margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.topMarginPercent = value;
    }

    value =
        array.getFraction(styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent right margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.rightMarginPercent = value;
    }

    value =
        array.getFraction(styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent bottom margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.bottomMarginPercent = value;
    }

    value =
        array.getFraction(styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent start margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.startMarginPercent = value;
    }

    value = array.getFraction(styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1, -1.0F);
    if (value != -1.0F) {
      if (Log.isLoggable("PercentLayout", 2)) {
        Log.v("PercentLayout", "percent end margin: " + value);
      }

      info = info != null ? info : new PercentLayoutHelper.PercentLayoutInfo();
      info.endMarginPercent = value;
    }

    array.recycle();
    if (Log.isLoggable("PercentLayout", 3)) {
      Log.d("PercentLayout", "constructed: " + info);
    }

    return info;
  }
    public LayoutParams(Context c, AttributeSet attrs) {
      super(c, attrs);

      TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.SpringLayout_Layout);

      final int[] relations = this.relations;

      final int N = a.getIndexCount();
      for (int i = 0; i < N; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.SpringLayout_Layout_layout_toLeftOf) {
          relations[LEFT_OF] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_toRightOf) {
          relations[RIGHT_OF] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_above) {
          relations[ABOVE] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_below) {
          relations[BELOW] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignLeft) {
          relations[ALIGN_LEFT] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignTop) {
          relations[ALIGN_TOP] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignRight) {
          relations[ALIGN_RIGHT] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignBottom) {
          relations[ALIGN_BOTTOM] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignCenter) {
          relations[ALIGN_CENTER] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignCenterHorizontally) {
          relations[ALIGN_CENTER_HORIZONTALLY] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignCenterVertically) {
          relations[ALIGN_CENTER_VERTICALLY] = a.getResourceId(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignParentLeft) {
          relations[ALIGN_PARENT_LEFT] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignParentTop) {
          relations[ALIGN_PARENT_TOP] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignParentRight) {
          relations[ALIGN_PARENT_RIGHT] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_alignParentBottom) {
          relations[ALIGN_PARENT_BOTTOM] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_centerInParent) {
          relations[CENTER_IN_PARENT] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_centerHorizontal) {
          relations[CENTER_HORIZONTAL] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_centerVertical) {
          relations[CENTER_VERTICAL] = a.getBoolean(attr, false) ? TRUE : 0;

        } else if (attr == R.styleable.SpringLayout_Layout_layout_relativeWidth) {
          relativeWidth = (int) a.getFraction(attr, RELATIVE_SIZE_DENOMINATOR, 1, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_relativeHeight) {
          relativeHeight = (int) a.getFraction(attr, RELATIVE_SIZE_DENOMINATOR, 1, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_widthWeight) {
          widthWeight = a.getInteger(attr, 0);

        } else if (attr == R.styleable.SpringLayout_Layout_layout_heightWeight) {
          heightWeight = a.getInteger(attr, 0);
        }
      }

      a.recycle();
    }
    public Builder(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
      TypedArray a =
          context.obtainStyledAttributes(
              attrs, R.styleable.LinearProgressDrawable, defStyleAttr, defStyleRes);
      int resId;

      progressPercent(a.getFloat(R.styleable.LinearProgressDrawable_pv_progress, 0));
      secondaryProgressPercent(
          a.getFloat(R.styleable.LinearProgressDrawable_pv_secondaryProgress, 0));

      TypedValue value = a.peekValue(R.styleable.LinearProgressDrawable_lpd_maxLineWidth);
      if (value == null) maxLineWidth(0.75f);
      else if (value.type == TypedValue.TYPE_FRACTION)
        maxLineWidth(
            a.getFraction(R.styleable.LinearProgressDrawable_lpd_maxLineWidth, 1, 1, 0.75f));
      else
        maxLineWidth(
            a.getDimensionPixelSize(R.styleable.LinearProgressDrawable_lpd_maxLineWidth, 0));

      value = a.peekValue(R.styleable.LinearProgressDrawable_lpd_minLineWidth);
      if (value == null) minLineWidth(0.25f);
      else if (value.type == TypedValue.TYPE_FRACTION)
        minLineWidth(
            a.getFraction(R.styleable.LinearProgressDrawable_lpd_minLineWidth, 1, 1, 0.25f));
      else
        minLineWidth(
            a.getDimensionPixelSize(R.styleable.LinearProgressDrawable_lpd_minLineWidth, 0));

      strokeSize(
          a.getDimensionPixelSize(
              R.styleable.LinearProgressDrawable_lpd_strokeSize, ThemeUtil.dpToPx(context, 4)));
      verticalAlign(
          a.getInteger(
              R.styleable.LinearProgressDrawable_lpd_verticalAlign,
              LinearProgressDrawable.ALIGN_BOTTOM));
      strokeColors(
          a.getColor(
              R.styleable.LinearProgressDrawable_lpd_strokeColor,
              ThemeUtil.colorPrimary(context, 0xFF000000)));
      if ((resId = a.getResourceId(R.styleable.LinearProgressDrawable_lpd_strokeColors, 0)) != 0) {
        TypedArray ta = context.getResources().obtainTypedArray(resId);
        int[] colors = new int[ta.length()];
        for (int j = 0; j < ta.length(); j++) colors[j] = ta.getColor(j, 0);
        ta.recycle();
        strokeColors(colors);
      }
      strokeSecondaryColor(
          a.getColor(R.styleable.LinearProgressDrawable_lpd_strokeSecondaryColor, 0));
      reverse(a.getBoolean(R.styleable.LinearProgressDrawable_lpd_reverse, false));
      travelDuration(
          a.getInteger(
              R.styleable.LinearProgressDrawable_lpd_travelDuration,
              context.getResources().getInteger(android.R.integer.config_longAnimTime)));
      transformDuration(
          a.getInteger(
              R.styleable.LinearProgressDrawable_lpd_transformDuration,
              context.getResources().getInteger(android.R.integer.config_mediumAnimTime)));
      keepDuration(
          a.getInteger(
              R.styleable.LinearProgressDrawable_lpd_keepDuration,
              context.getResources().getInteger(android.R.integer.config_shortAnimTime)));
      if ((resId = a.getResourceId(R.styleable.LinearProgressDrawable_lpd_transformInterpolator, 0))
          != 0) transformInterpolator(AnimationUtils.loadInterpolator(context, resId));
      progressMode(
          a.getInteger(
              R.styleable.LinearProgressDrawable_pv_progressMode, ProgressView.MODE_INDETERMINATE));
      inAnimDuration(
          a.getInteger(
              R.styleable.LinearProgressDrawable_lpd_inAnimDuration,
              context.getResources().getInteger(android.R.integer.config_mediumAnimTime)));
      outAnimDuration(
          a.getInteger(
              R.styleable.LinearProgressDrawable_lpd_outAnimDuration,
              context.getResources().getInteger(android.R.integer.config_mediumAnimTime)));

      a.recycle();
    }