示例#1
0
  /**
   * 获取自定义属性
   *
   * @param attrs
   */
  private void obtainStyledAttributes(AttributeSet attrs) {
    metrics = getContext().getResources().getDisplayMetrics();
    framePadding =
        (int)
            TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_FRAME_PADDING, metrics);
    frameWidth =
        (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_FRAME_WIDTH, metrics);

    TypedArray mTypedArray = getContext().obtainStyledAttributes(attrs, R.styleable.WaterMarkView);

    Drawable srcDrawble = mTypedArray.getDrawable(R.styleable.WaterMarkView_src);
    if (srcDrawble instanceof BitmapDrawable) {
      BitmapDrawable bd = (BitmapDrawable) srcDrawble;
      this.mWaterMarkBitmap = bd.getBitmap();
    }

    framePadding =
        mTypedArray.getDimensionPixelSize(R.styleable.WaterMarkView_framePadding, framePadding);
    frameWidth =
        mTypedArray.getDimensionPixelSize(R.styleable.WaterMarkView_frameWidth, frameWidth);
    frameColor = mTypedArray.getColor(R.styleable.WaterMarkView_frameColor, DEFAULT_FRAME_COLOR);
    mScale = mTypedArray.getFloat(R.styleable.WaterMarkView_scale, DEFAULT_SCALE);
    mDegree = mTypedArray.getFloat(R.styleable.WaterMarkView_degree, DEFAULT_DEGREE);
    controlDrawable = mTypedArray.getDrawable(R.styleable.WaterMarkView_controlDrawable);
    controlLocation =
        mTypedArray.getInt(R.styleable.WaterMarkView_controlLocation, DEFAULT_CONTROL_LOCATION);
    isEditable = mTypedArray.getBoolean(R.styleable.WaterMarkView_editable, DEFAULT_EDITABLE);

    mTypedArray.recycle();
  }
示例#2
0
  private void initSeekBar(AttributeSet attrs, int defStyleAttr) {
    if (isInEditMode()) return;

    colorControl = Carbon.getThemeColor(getContext(), R.attr.colorControlNormal);

    thumbRadius = thumbRadius2 = THUMB_RADIUS = Carbon.getDip(getContext()) * 8;
    THUMB_RADIUS_DRAGGED = Carbon.getDip(getContext()) * 10;
    STROKE_WIDTH = Carbon.getDip(getContext()) * 2;

    if (attrs != null) {
      Carbon.initAnimations(this, attrs, defStyleAttr);
      Carbon.initTint(this, attrs, defStyleAttr);
      Carbon.initRippleDrawable(this, attrs, defStyleAttr);

      TypedArray a =
          getContext().obtainStyledAttributes(attrs, R.styleable.SeekBar, defStyleAttr, 0);

      setStyle(Style.values()[a.getInt(R.styleable.SeekBar_carbon_barStyle, 0)]);
      setMin(a.getFloat(R.styleable.SeekBar_carbon_min, 0));
      setMax(a.getFloat(R.styleable.SeekBar_carbon_max, 0));
      setStepSize(a.getFloat(R.styleable.SeekBar_carbon_stepSize, 0));
      setValue(a.getFloat(R.styleable.SeekBar_carbon_value, 0));
      setValue2(a.getFloat(R.styleable.SeekBar_carbon_value2, 0));

      a.recycle();
    }

    setFocusableInTouchMode(false); // TODO: from theme
  }
示例#3
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();
  }
  public DragSortListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mRemoveMode = FLING;
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    if (attrs != null) {
      TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.DragSortListView, 0, 0);

      mItemHeightCollapsed =
          a.getDimensionPixelSize(
              R.styleable.DragSortListView_collapsed_height, mItemHeightCollapsed);

      mTrackDragScroll = a.getBoolean(R.styleable.DragSortListView_track_drag_scroll, false);

      mFloatBGColor = a.getColor(R.styleable.DragSortListView_float_background_color, 0x00000000);

      mRemoveMode = a.getInt(R.styleable.DragSortListView_remove_mode, -1);

      float frac =
          a.getFloat(R.styleable.DragSortListView_drag_scroll_start, mDragUpScrollStartFrac);
      setDragScrollStart(frac);

      mMaxScrollSpeed =
          a.getFloat(R.styleable.DragSortListView_max_drag_scroll_speed, mMaxScrollSpeed);

      a.recycle();
    }

    // Log.d("mobeta", "collapsed height=" + mItemHeightCollapsed);

    mDragScroller = new DragScroller();
    setOnScrollListener(mDragScroller);
  }
示例#5
0
  public RatingBar(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RatingBar, defStyle, 0);
    final int numStars = a.getInt(R.styleable.RatingBar_numStars, mNumStars);
    setIsIndicator(a.getBoolean(R.styleable.RatingBar_isIndicator, !mIsUserSeekable));
    final float rating = a.getFloat(R.styleable.RatingBar_rating, -1);
    final float stepSize = a.getFloat(R.styleable.RatingBar_stepSize, -1);
    a.recycle();

    if (numStars > 0 && numStars != mNumStars) {
      setNumStars(numStars);
    }

    if (stepSize >= 0) {
      setStepSize(stepSize);
    } else {
      setStepSize(0.5f);
    }

    if (rating >= 0) {
      setRating(rating);
    }

    // A touch inside a star fill up to that fractional area (slightly more
    // than 1 so boundaries round up).
    mTouchProgressOffset = 1.1f;
  }
  public DecelerateInterpolatorEx(Context context, AttributeSet attrs) {
    TypedArray a =
        context.obtainStyledAttributes(
            attrs, com.mediatek.internal.R.styleable.DecelerateInterpolatorEx);

    mFactor = a.getFloat(com.mediatek.internal.R.styleable.DecelerateInterpolatorEx_factor, 1.0f);
    mScale = a.getFloat(com.mediatek.internal.R.styleable.DecelerateInterpolatorEx_scale, 1.0f);

    a.recycle();
  }
 private void initTypeArray(Context context, AttributeSet attrs) {
   TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar);
   progressbarColor =
       typedArray.getColor(R.styleable.CircleProgressBar_circleBarColor, Color.GREEN);
   currentProgress = typedArray.getFloat(R.styleable.CircleProgressBar_currentProgress, 10);
   maxProgress = typedArray.getFloat(R.styleable.CircleProgressBar_maxProgress, 100);
   circleBarWidth = typedArray.getFloat(R.styleable.CircleProgressBar_circleBarWidth, 5);
   if (currentProgress > maxProgress) currentProgress = maxProgress;
   typedArray.recycle();
 }
  public PaperButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mPadding = getResources().getDimensionPixelSize(R.dimen.paper_padding);
    TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.PaperButton);
    mColor =
        attributes.getColor(
            R.styleable.PaperButton_paper_color,
            getResources().getColor(R.color.paper_button_color));
    mShadowColor =
        attributes.getColor(
            R.styleable.PaperButton_paper_shadow_color,
            getResources().getColor(R.color.paper_button_shadow_color));
    mCornerRadius =
        attributes.getDimensionPixelSize(
            R.styleable.PaperButton_paper_corner_radius,
            getResources().getDimensionPixelSize(R.dimen.paper_button_corner_radius));
    mText = attributes.getText(R.styleable.PaperButton_paper_text);
    mTextSize =
        attributes.getDimensionPixelSize(
            R.styleable.PaperButton_paper_text_size,
            getResources().getDimensionPixelSize(R.dimen.paper_text_size));
    mTextColor =
        attributes.getColor(
            R.styleable.PaperButton_paper_text_color,
            getResources().getColor(R.color.paper_text_color));
    final String assetPath = attributes.getString(R.styleable.PaperButton_paper_font);
    if (assetPath != null) {
      AssetManager assets = context.getAssets();
      Typeface typeface = Typeface.createFromAsset(assets, assetPath);
      textPaint.setTypeface(typeface);
    }
    mShadowRadius = attributes.getFloat(R.styleable.PaperButton_paper_shadow_radius, SHADOW_RADIUS);
    mShadowOffsetX =
        attributes.getFloat(R.styleable.PaperButton_paper_shadow_offset_x, SHADOW_OFFSET_X);
    mShadowOffsetY =
        attributes.getFloat(R.styleable.PaperButton_paper_shadow_offset_y, SHADOW_OFFSET_Y);
    attributes.recycle();

    backgroundPaint.setColor(mColor);
    backgroundPaint.setStyle(Paint.Style.FILL);
    int shadowColor = changeColorAlpha(mShadowColor, MIN_SHADOW_COLOR_ALPHA);
    backgroundPaint.setShadowLayer(mShadowRadius, mShadowOffsetX, mShadowOffsetY, shadowColor);

    textPaint.setColor(mTextColor);
    textPaint.setTextSize(mTextSize);
    textPaint.setTextAlign(TextPaint.Align.CENTER);

    ripplePaint.setColor(darkenColor(mColor));

    setWillNotDraw(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
  }
  /**
   * Constructor.
   *
   * @param context
   * @param attrs
   * @param defStyle
   */
  public GlslSliderPreference(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Get values from preferences xml.
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SliderPreference);
    mValueMin = ta.getFloat(R.styleable.SliderPreference_valueMin, 0);
    mValueMax = ta.getFloat(R.styleable.SliderPreference_valueMax, 100);
    mValuePrecision = ta.getFloat(R.styleable.SliderPreference_valuePrecision, 1);

    // Store original title for later use.
    mTitle = getTitle().toString();
    setDialogLayoutResource(R.layout.slider);
  }
  public ParallaxImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Instantiate future objects
    mTranslationMatrix = new Matrix();
    mSensorInterpreter = new SensorInterpreter();

    // Sets scale type
    setScaleType(ScaleType.MATRIX);

    // Set available attributes
    if (attrs != null) {
      final TypedArray customAttrs =
          context.obtainStyledAttributes(attrs, R.styleable.ParallaxImageView);

      if (customAttrs != null) {
        if (customAttrs.hasValue(R.styleable.ParallaxImageView_intensity))
          setParallaxIntensity(
              customAttrs.getFloat(R.styleable.ParallaxImageView_intensity, mParallaxIntensity));

        if (customAttrs.hasValue(R.styleable.ParallaxImageView_scaledIntensity))
          setScaledIntensities(
              customAttrs.getBoolean(
                  R.styleable.ParallaxImageView_scaledIntensity, mScaledIntensities));

        if (customAttrs.hasValue(R.styleable.ParallaxImageView_tiltSensitivity))
          setTiltSensitivity(
              customAttrs.getFloat(
                  R.styleable.ParallaxImageView_tiltSensitivity,
                  mSensorInterpreter.getTiltSensitivity()));

        if (customAttrs.hasValue(R.styleable.ParallaxImageView_forwardTiltOffset))
          setForwardTiltOffset(
              customAttrs.getFloat(
                  R.styleable.ParallaxImageView_forwardTiltOffset,
                  mSensorInterpreter.getForwardTiltOffset()));

        customAttrs.recycle();
      }
    }

    // Configure matrix as early as possible by posting to MessageQueue
    post(
        new Runnable() {
          @Override
          public void run() {
            configureMatrix();
          }
        });
  }
  private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.ToggleImageButton, defStyle, 0);
    boolean checked = a.getBoolean(R.styleable.ToggleImageButton_android_checked, false);
    setChecked(checked);
    mSrcDrawable = a.getDrawable(R.styleable.ToggleImageButton_android_src);
    mTintColor = a.getColor(R.styleable.ToggleImageButton_android_tint, 0);
    mCheckedDrawable = a.getDrawable(R.styleable.ToggleImageButton_checkedSrc);
    mCheckedTintColor = a.getColor(R.styleable.ToggleImageButton_checkedTint, 0);
    mBlurRadius = a.getFloat(R.styleable.ToggleImageButton_checkedBlurRadius, 0);
    a.recycle();

    super.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            setChecked(!isChecked(), true);
          }
        });

    if (mBlurRadius != 0.0f) {
      Drawable drawable = resolveCheckedDrawable();
      if (BuildConfig.DEBUG) Log.d(LOG_TAG, "Checked drawable is a " + drawable.toString());
      if (drawable instanceof BitmapDrawable) {
        BitmapDrawable bd = (BitmapDrawable) drawable;
        Paint paint = new Paint();
        paint.setMaskFilter(new BlurMaskFilter(mBlurRadius, BlurMaskFilter.Blur.SOLID));
        Bitmap bitmap = bd.getBitmap().extractAlpha(paint, null);
        mCheckedDrawable = new BitmapDrawable(getContext().getResources(), bitmap);
      }
    }
  }
示例#12
0
  public DoubleProgress(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.DoubleProgress);
    try {
      stringHaut = styledAttrs.getString(R.styleable.DoubleProgress_texteHaut);
      stringBas = styledAttrs.getString(R.styleable.DoubleProgress_texteBas);
      max = styledAttrs.getFloat(R.styleable.DoubleProgress_max, 5);
      temps = styledAttrs.getInt(R.styleable.DoubleProgress_temps, 1000);
      attente = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
      textFromAlpha = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
      textToAlpha = styledAttrs.getInt(R.styleable.DoubleProgress_attente, 0);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      styledAttrs.recycle();
    }

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mView = inflater.inflate(R.layout.double_progress, this, true); // ajoute la view

    charger();
    remplir();
  }
  public MaterialRippleLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(false);
    gestureDetector = new GestureDetector(context, longClickListener);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MaterialRippleLayout);
    rippleColor = a.getColor(R.styleable.MaterialRippleLayout_mrl_rippleColor, DEFAULT_COLOR);
    rippleDiameter =
        a.getDimensionPixelSize(
            R.styleable.MaterialRippleLayout_rippleDimension,
            (int) dpToPx(getResources(), DEFAULT_DIAMETER_DP));
    rippleOverlay =
        a.getBoolean(R.styleable.MaterialRippleLayout_rippleOverlay, DEFAULT_RIPPLE_OVERLAY);
    rippleHover = a.getBoolean(R.styleable.MaterialRippleLayout_rippleHover, DEFAULT_HOVER);
    rippleDuration = a.getInt(R.styleable.MaterialRippleLayout_rippleDuration, DEFAULT_DURATION);
    rippleAlpha =
        (int) (255 * a.getFloat(R.styleable.MaterialRippleLayout_rippleAlpha, DEFAULT_ALPHA));
    rippleDelayClick =
        a.getBoolean(R.styleable.MaterialRippleLayout_rippleDelayClick, DEFAULT_DELAY_CLICK);
    rippleFadeDuration =
        a.getInteger(R.styleable.MaterialRippleLayout_rippleFadeDuration, DEFAULT_FADE_DURATION);
    rippleBackground =
        new ColorDrawable(
            a.getColor(R.styleable.MaterialRippleLayout_rippleBackground, DEFAULT_BACKGROUND));
    ripplePersistent =
        a.getBoolean(R.styleable.MaterialRippleLayout_ripplePersistent, DEFAULT_PERSISTENT);
    rippleInAdapter =
        a.getBoolean(R.styleable.MaterialRippleLayout_rippleInAdapter, DEFAULT_SEARCH_ADAPTER);

    a.recycle();

    paint.setColor(rippleColor);
    paint.setAlpha(rippleAlpha);
  }
 public WeightProgressBar(Context context, AttributeSet attributeSet, int i) {
   super(context, attributeSet, i);
   this.a = null;
   this.b = 0.0f;
   this.c = 0;
   this.d = 0;
   this.e = 0;
   this.f = 0;
   this.g = 150.0f;
   this.h = 0.0f;
   this.i = 0.0f;
   TypedArray obtainStyledAttributes =
       context.obtainStyledAttributes(attributeSet, t.WeightProgressBar);
   this.b = obtainStyledAttributes.getDimension(0, BitmapDescriptorFactory.HUE_ORANGE);
   this.c = obtainStyledAttributes.getColor(1, -1);
   this.e = obtainStyledAttributes.getColor(3, -10919831);
   this.d = obtainStyledAttributes.getColor(2, -12827569);
   this.f = obtainStyledAttributes.getColor(4, -8476672);
   this.g = (float) obtainStyledAttributes.getInteger(5, a.ap);
   this.h = obtainStyledAttributes.getFloat(6, 0.0f);
   this.i = obtainStyledAttributes.getFloat(6, 0.0f);
   obtainStyledAttributes.recycle();
   this.a = new Paint();
   this.a.setColor(this.e);
   this.a.setStyle(Style.STROKE);
   this.a.setStrokeWidth(this.b);
   this.a.setAntiAlias(true);
 }
 private void initAttrs(Context context, AttributeSet attrs) {
   TypedArray array =
       context.obtainStyledAttributes(attrs, R.styleable.DownloadProgressView, 0, 0);
   try {
     mRadius = array.getDimension(R.styleable.DownloadProgressView_circleRadius, 0);
     mStrokeWidth = array.getDimension(R.styleable.DownloadProgressView_strokeWidth, 0);
     mLineWidth = array.getDimension(R.styleable.DownloadProgressView_lineWidth, 0);
     mProgressDuration =
         array.getInteger(
             R.styleable.DownloadProgressView_progressDuration, DEFAULT_PROGRESS_DURATION);
     mResultDuration =
         array.getInteger(
             R.styleable.DownloadProgressView_resultDuration, DEFAULT_RESULT_DURATION);
     mProgressBackgroundColor =
         array.getColor(R.styleable.DownloadProgressView_progressBackgroundColor, 0);
     mDrawingColor = array.getColor(R.styleable.DownloadProgressView_drawingColor, 0);
     mProgressColor = array.getColor(R.styleable.DownloadProgressView_progressColor, 0);
     mCircleBackgroundColor =
         array.getColor(R.styleable.DownloadProgressView_circleBackgroundColor, 0);
     mOvershootValue =
         array.getFloat(R.styleable.DownloadProgressView_overshootValue, DEFAULT_OVERSHOOT_VALUE);
   } finally {
     array.recycle();
   }
 }
  public AspectRatioImageView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AspectRatioImageView);
    mAspectRatio = a.getFloat(R.styleable.AspectRatioImageView_aspect_ratio, DEFAULT_ASPECT_RATIO);
    a.recycle();
  }
  public ColorTrackView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ColorTrackView);
    mText = ta.getString(R.styleable.ColorTrackView_text);
    mTextNormalSize =
        ta.getDimensionPixelSize(R.styleable.ColorTrackView_text_normal_size, mTextNormalSize);
    mTextSelectSize =
        ta.getDimensionPixelSize(R.styleable.ColorTrackView_text_select_size, mTextNormalSize);

    mTextOriginColor = ta.getColor(R.styleable.ColorTrackView_text_origin_color, mTextOriginColor);

    mTextChangeColor = ta.getColor(R.styleable.ColorTrackView_text_change_color, mTextChangeColor);
    mProgress = ta.getFloat(R.styleable.ColorTrackView_progress, 0);

    mDirection = ta.getInt(R.styleable.ColorTrackView_direction, mDirection);

    bSelected = ta.getBoolean(R.styleable.ColorTrackView_isSelect, bSelected);

    ta.recycle();

    mPaint.setTextSize(mTextNormalSize);
    measureText();

    mTextOriginColorR = (mTextChangeColor & 0xff0000) >> 16;
    mTextOriginColorG = (mTextChangeColor & 0x00ff00) >> 8;
    mTextOriginColorB = (mTextChangeColor & 0x0000ff);
  }
示例#18
0
 protected void initByAttributes(TypedArray attributes) {
   finishedStrokeColor =
       attributes.getColor(R.styleable.ArcProgress_arc_finished_color, default_finished_color);
   unfinishedStrokeColor =
       attributes.getColor(R.styleable.ArcProgress_arc_unfinished_color, default_unfinished_color);
   textColor = attributes.getColor(R.styleable.ArcProgress_arc_text_color, default_text_color);
   textSize = attributes.getDimension(R.styleable.ArcProgress_arc_text_size, default_text_size);
   arcAngle = attributes.getFloat(R.styleable.ArcProgress_arc_angle, default_arc_angle);
   setMax(attributes.getInt(R.styleable.ArcProgress_arc_max, default_max));
   setProgress(attributes.getInt(R.styleable.ArcProgress_arc_progress, 0));
   strokeWidth =
       attributes.getDimension(R.styleable.ArcProgress_arc_stroke_width, default_stroke_width);
   suffixTextSize =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_suffix_text_size, default_suffix_text_size);
   suffixText =
       TextUtils.isEmpty(attributes.getString(R.styleable.ArcProgress_arc_suffix_text))
           ? default_suffix_text
           : attributes.getString(R.styleable.ArcProgress_arc_suffix_text);
   suffixTextPadding =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_suffix_text_padding, default_suffix_padding);
   bottomTextSize =
       attributes.getDimension(
           R.styleable.ArcProgress_arc_bottom_text_size, default_bottom_text_size);
   bottomText = attributes.getString(R.styleable.ArcProgress_arc_bottom_text);
 }
  public static BeveledTileAttributeSet extractAttributes(Context context, AttributeSet attrs) {
    BeveledTileAttributeSet beveledTileAttributeSet = null;

    TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.BeveledTileView);

    try {
      int[] colorList = new int[BeveledTileDrawable.REQUIRED_COLOR_COUNT];

      colorList[INNER_RECT_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_innerRectColor, -1);
      colorList[LEFT_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_leftBevelColor, -1);
      colorList[TOP_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_topBevelColor, -1);
      colorList[RIGHT_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_rightBevelColor, -1);
      colorList[BOTTOM_BEVEL_COLOR_INDICE] =
          attributesArray.getColor(R.styleable.BeveledTileView_bottomBevelColor, -1);
      float fillPercent = attributesArray.getFloat(R.styleable.BeveledTileView_fillPercentage, -1);

      beveledTileAttributeSet = new BeveledTileAttributeSet(colorList, fillPercent);
    } finally {
      attributesArray.recycle();
      return beveledTileAttributeSet;
    }
  }
示例#20
0
 /**
  * Parse the attributes passed to the view from the XML
  *
  * @param a the attributes to parse
  */
 private void parseAttributes(TypedArray a) {
   // We transform the default values from DIP to pixels
   DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
   barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
   rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
   circleRadius =
       (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);
   circleRadius =
       (int) a.getDimension(R.styleable.ProgressWheel_matProg_circleRadius, circleRadius);
   fillRadius = a.getBoolean(R.styleable.ProgressWheel_matProg_fillRadius, false);
   barWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_barWidth, barWidth);
   rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_matProg_rimWidth, rimWidth);
   float baseSpinSpeed =
       a.getFloat(R.styleable.ProgressWheel_matProg_spinSpeed, spinSpeed / 360.0f);
   spinSpeed = baseSpinSpeed * 360;
   barSpinCycleTime =
       a.getInt(R.styleable.ProgressWheel_matProg_barSpinCycleTime, (int) barSpinCycleTime);
   barColor = a.getColor(R.styleable.ProgressWheel_matProg_barColor, barColor);
   rimColor = a.getColor(R.styleable.ProgressWheel_matProg_rimColor, rimColor);
   linearProgress = a.getBoolean(R.styleable.ProgressWheel_matProg_linearProgress, false);
   if (a.getBoolean(R.styleable.ProgressWheel_matProg_progressIndeterminate, false)) {
     spin();
   }
   // Recycle
   a.recycle();
 }
  public void init(
      @NonNull View view, @Nullable AttributeSet attrs, @NonNull TextPaint baseTextPaint) {
    final Context context = view.getContext();
    final int defColor = baseTextPaint.getColor();
    final int defPadding =
        context.getResources().getDimensionPixelSize(R.dimen.drag_direction_text_default_padding);
    final float minTextSize =
        context.getResources().getDimensionPixelSize(R.dimen.drag_direction_text_min_size);

    if (attrs == null) {
      for (DragDirection direction : DragDirection.values()) {
        final Text text = new Text(direction, view, minTextSize);
        text.init(baseTextPaint, null, DEF_SCALE, defColor, DEF_ALPHA, defPadding);
        texts.put(direction, text);
      }
      return;
    }
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DirectionText);
    final float scale = array.getFloat(R.styleable.DirectionText_directionTextScale, DEF_SCALE);
    final float alpha = array.getFloat(R.styleable.DirectionText_directionTextAlpha, DEF_ALPHA);
    final int color = array.getColor(R.styleable.DirectionText_directionTextColor, defColor);
    final int padding =
        array.getDimensionPixelSize(R.styleable.DirectionText_directionTextPadding, defPadding);
    for (DragDirection direction : DragDirection.values()) {
      final Text text = new Text(direction, view, minTextSize);
      text.init(baseTextPaint, array, scale, color, alpha, padding);
      texts.put(direction, text);
    }
    array.recycle();
  }
示例#22
0
  public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    strokeWidth = 5f;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.com_displayer_CircleImageView);
    strokeWidth = a.getFloat(R.styleable.com_displayer_CircleImageView_stroke_width, 5f);
    String tempColor = a.getString(R.styleable.com_displayer_CircleImageView_stroke_color);
    Log.d("CircularImageView", "ColorTag: " + tempColor);

    if (tempColor != null && !tempColor.equalsIgnoreCase("#0")) {
      String black = tempColor.replaceAll("0", "");
      String white = tempColor.replaceAll("f", "");
      white = white.replaceAll("F", "");

      if (black.equalsIgnoreCase("#")) {
        tempColor = "#000000";
      }

      if (white.equalsIgnoreCase("#")) {
        tempColor = "#ffffff";
      }

      strokeColor = Color.parseColor(tempColor);
    } else {
      strokeColor = Color.TRANSPARENT;
    }
    a.recycle();
  }
 public LinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
   super(context, attrs, defStyleAttr, defStyleRes);
   this.mBaselineAligned = true;
   this.mBaselineAlignedChildIndex = -1;
   this.mBaselineChildTop = SHOW_DIVIDER_NONE;
   this.mGravity = 8388659;
   TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.LinearLayout, defStyleAttr, defStyleRes);
   int index = a.getInt(VERTICAL, -1);
   if (index >= 0) {
     setOrientation(index);
   }
   index = a.getInt(SHOW_DIVIDER_NONE, -1);
   if (index >= 0) {
     setGravity(index);
   }
   boolean baselineAligned = a.getBoolean(SHOW_DIVIDER_MIDDLE, true);
   if (!baselineAligned) {
     setBaselineAligned(baselineAligned);
   }
   this.mWeightSum =
       a.getFloat(
           VERTICAL_GRAVITY_COUNT,
           android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE);
   this.mBaselineAlignedChildIndex = a.getInt(INDEX_FILL, -1);
   this.mUseLargestChild = a.getBoolean(6, false);
   setDividerDrawable(a.getDrawable(5));
   this.mShowDividers = a.getInt(7, SHOW_DIVIDER_NONE);
   this.mDividerPadding = a.getDimensionPixelSize(8, SHOW_DIVIDER_NONE);
   a.recycle();
 }
示例#24
0
  public SimpleScroller(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    final TypedArray attributes =
        context.obtainStyledAttributes(attrs, R.styleable.SimpleScroller, defStyleAttr, 0);

    try {
      mHandedness =
          Handedness.values()[attributes.getInt(R.styleable.SimpleScroller_handedness, 0)];

      mArrowHeight = attributes.getDimension(R.styleable.SimpleScroller_arrowHeight, 25f);
      mTicWidth = attributes.getDimension(R.styleable.SimpleScroller_ticWidth, 16f);
      mTextHorizontalMargin =
          attributes.getDimension(R.styleable.SimpleScroller_textHorizontalMargin, 23f);
      mTextVerticalMargin =
          attributes.getDimension(R.styleable.SimpleScroller_textVerticalMargin, 10f);

      mStrokeColor = new Paint();
      mStrokeColor.setAntiAlias(true);
      mStrokeColor.setStyle(Paint.Style.STROKE);
      mStrokeColor.setTextAlign(
          mHandedness == Handedness.LEFT ? Paint.Align.RIGHT : Paint.Align.LEFT);
      mStrokeColor.setStrokeWidth(DEFAULT_STROKE_WIDTH);
      mStrokeColor.setColor(
          attributes.getColor(R.styleable.SimpleScroller_strokeColor, Color.WHITE));
      mStrokeColor.setTextSize(
          attributes.getDimension(R.styleable.SimpleScroller_android_textSize, 25f));

      mArrowStrokeColor = new Paint();
      mArrowStrokeColor.setAntiAlias(true);
      mArrowStrokeColor.setStyle(Paint.Style.STROKE);
      mArrowStrokeColor.setStrokeWidth(DEFAULT_STROKE_WIDTH);
      mArrowStrokeColor.setColor(
          attributes.getColor(R.styleable.SimpleScroller_arrowStrokeColor, Color.WHITE));

      mArrowBgColor = new Paint();
      mArrowBgColor.setAntiAlias(true);
      mArrowBgColor.setStyle(Paint.Style.FILL);
      mArrowBgColor.setColor(
          attributes.getColor(R.styleable.SimpleScroller_arrowBgColor, Color.BLACK));

      mScrollTo = attributes.getFloat(R.styleable.SimpleScroller_scrollTo, 0);
      mScrollToRange = attributes.getFloat(R.styleable.SimpleScroller_scrollToRange, 26f);
    } finally {
      attributes.recycle();
    }
  }
  /**
   * Instantiates a new holo circular progress bar.
   *
   * @param context the context
   * @param attrs the attrs
   * @param defStyle the def style
   */
  public HoloCircularProgressBar(
      final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);

    // load the styled attributes and set their properties
    final TypedArray attributes =
        context.obtainStyledAttributes(attrs, R.styleable.HoloCircularProgressBar, defStyle, 0);

    setProgressColor(
        attributes.getColor(R.styleable.HoloCircularProgressBar_progress_color, Color.GREEN));
    setProgressBackgroundColor(
        attributes.getColor(
            R.styleable.HoloCircularProgressBar_progress_background_color, Color.LTGRAY));
    setProgress(attributes.getFloat(R.styleable.HoloCircularProgressBar_progress, 0.0f));
    setMarkerProgress(
        attributes.getFloat(R.styleable.HoloCircularProgressBar_marker_progress, 0.0f));
    setWheelSize(
        (int)
            attributes.getDimension(
                R.styleable.HoloCircularProgressBar_stroke_width,
                80)); // 1507 set the width of circle
    mIsThumbEnabled =
        attributes.getBoolean(
            R.styleable.HoloCircularProgressBar_thumb_visible,
            false); // 1507 to hide the thumb on landing screen
    mIsMarkerEnabled =
        attributes.getBoolean(
            R.styleable.HoloCircularProgressBar_marker_visible,
            false); // 1507 to hide the marker on lading screen

    mGravity =
        attributes.getInt(R.styleable.HoloCircularProgressBar_android_gravity, Gravity.CENTER);

    attributes.recycle();

    mThumbRadius = mCircleStrokeWidth * 2;

    updateBackgroundColor();

    updateMarkerColor();

    updateProgressColor();

    // the view has now all properties and can be drawn
    mIsInitializing = false;
  }
 public LayoutParams(Context c, AttributeSet attrs) {
   super(c, attrs);
   this.gravity = -1;
   TypedArray a = c.obtainStyledAttributes(attrs, R.styleable.LinearLayout_Layout);
   this.weight = a.getFloat(LinearLayout.INDEX_FILL, 0.0f);
   this.gravity = a.getInt(LinearLayout.SHOW_DIVIDER_NONE, -1);
   a.recycle();
 }
示例#27
0
 public LayoutParams(Context context, AttributeSet attr) {
   super(context, attr);
   TypedArray ta = context.obtainStyledAttributes(attr, R.styleable.DragNDrapLayout);
   this.x = (int) ta.getDimension(R.styleable.DragNDrapLayout_android_layout_x, 0.0f);
   this.y = (int) ta.getDimension(R.styleable.DragNDrapLayout_android_layout_y, 0.0f);
   this.isScalable = ta.getBoolean(R.styleable.DragNDrapLayout_layout_scalable, true);
   this.fScale = ta.getFloat(R.styleable.DragNDrapLayout_layout_scale, 1.0f);
 }
  public AccelerateInterpolator(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AccelerateInterpolator);

    mFactor = a.getFloat(R.styleable.AccelerateInterpolator_factor, 1.0f);
    mDoubleFactor = 2 * mFactor;

    a.recycle();
  }
示例#29
0
  /**
   * Does all the initial setup of the button such as retrieving all the attributes that were set in
   * xml and inflating the like button's view and initial state.
   *
   * @param context
   * @param attrs
   * @param defStyle
   */
  private void init(Context context, AttributeSet attrs, int defStyle) {
    LayoutInflater.from(getContext()).inflate(R.layout.likeview, this, true);
    icon = (ImageView) findViewById(R.id.icon);
    dotsView = (DotsView) findViewById(R.id.dots);
    circleView = (CircleView) findViewById(R.id.circle);

    final TypedArray array =
        context.obtainStyledAttributes(attrs, R.styleable.LikeButton, defStyle, 0);

    iconSize = array.getDimensionPixelSize(R.styleable.LikeButton_icon_size, -1);
    if (iconSize == -1) iconSize = 40;

    String iconType = array.getString(R.styleable.LikeButton_icon_type);

    likeDrawable = array.getDrawable(R.styleable.LikeButton_like_drawable);

    if (likeDrawable != null) setLikeDrawable(likeDrawable);

    unLikeDrawable = array.getDrawable(R.styleable.LikeButton_unlike_drawable);

    if (unLikeDrawable != null) setUnlikeDrawable(unLikeDrawable);

    if (iconType != null) if (!iconType.isEmpty()) currentIcon = parseIconType(iconType);

    circleStartColor = array.getColor(R.styleable.LikeButton_circle_start_color, 0);

    if (circleStartColor != 0) circleView.setStartColor(circleStartColor);

    circleEndColor = array.getColor(R.styleable.LikeButton_circle_end_color, 0);

    if (circleEndColor != 0) circleView.setEndColor(circleEndColor);

    dotPrimaryColor = array.getColor(R.styleable.LikeButton_dots_primary_color, 0);
    dotSecondaryColor = array.getColor(R.styleable.LikeButton_dots_secondary_color, 0);

    if (dotPrimaryColor != 0 && dotSecondaryColor != 0) {
      dotsView.setColors(dotPrimaryColor, dotSecondaryColor);
    }

    if (likeDrawable == null && unLikeDrawable == null) {
      if (currentIcon != null) {

        setLikeDrawableRes(currentIcon.getOnIconResourceId());
        setUnlikeDrawableRes(currentIcon.getOffIconResourceId());
      } else {
        currentIcon = parseIconType(IconType.Heart);
        setLikeDrawableRes(currentIcon.getOnIconResourceId());
        setUnlikeDrawableRes(currentIcon.getOffIconResourceId());
      }
    }

    setEnabled(array.getBoolean(R.styleable.LikeButton_enabled, true));
    Boolean status = array.getBoolean(R.styleable.LikeButton_liked, false);
    setAnimationScaleFactor(array.getFloat(R.styleable.LikeButton_anim_scale_factor, 3));
    setLiked(status);
    setOnClickListener(this);
    array.recycle();
  }
示例#30
0
  public BubbleView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mRandom = new Random();
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BubbleView);
    try {
      mBubbleNums = a.getInteger(R.styleable.BubbleView_bubbleNumber, 10);

      mBubbleMinRadius = a.getFloat(R.styleable.BubbleView_minRadius, 10.0f);
      mBubbleMaxRadius = a.getFloat(R.styleable.BubbleView_maxRadius, 20.0f);

      mMinSpeed = a.getFloat(R.styleable.BubbleView_minSpeed, 5.0f);
      mMaxSpeed = a.getFloat(R.styleable.BubbleView_maxSpeed, 10.0f);
    } finally {
      a.recycle();
    }
  }