Пример #1
0
        public RatingBar(android.content.Context context, android.util.AttributeSet attrs
                         , int defStyle) : base(context, attrs, defStyle)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.RatingBar, defStyle, 0);
            int numStars = a.getInt([email protected]_numStars, mNumStars
                                    );

            setIsIndicator(a.getBoolean([email protected]_isIndicator,
                                        !mIsUserSeekable));
            float rating   = a.getFloat([email protected]_rating, -1);
            float stepSize = a.getFloat([email protected]_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 AnticipateOvershootInterpolator(android.content.Context context, android.util.AttributeSet
                                        attrs)
 {
     android.content.res.TypedArray a_1 = context.obtainStyledAttributes(attrs, [email protected]
                                                                         .styleable.AnticipateOvershootInterpolator);
     mTension = a_1.getFloat([email protected]_tension
                             , 2.0f) * a_1.getFloat([email protected]_extraTension
                                                    , 1.5f);
     a_1.recycle();
 }
Пример #3
0
 /// <summary>Constructor used when an AlphaAnimation is loaded from a resource.</summary>
 /// <remarks>Constructor used when an AlphaAnimation is loaded from a resource.</remarks>
 /// <param name="context">Application context to use</param>
 /// <param name="attrs">Attribute set from which to read values</param>
 public AlphaAnimation(android.content.Context context, android.util.AttributeSet
                       attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.AlphaAnimation);
     mFromAlpha = a.getFloat([email protected]_fromAlpha, 1.0f
                             );
     mToAlpha = a.getFloat([email protected]_toAlpha, 1.0f);
     a.recycle();
 }
Пример #4
0
 public WeightedLinearLayout(android.content.Context context, android.util.AttributeSet
                             attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.WeightedLinearLayout);
     mMajorWeightMin = a.getFloat([email protected]_majorWeightMin
                                  , 0.0f);
     mMinorWeightMin = a.getFloat([email protected]_minorWeightMin
                                  , 0.0f);
     mMajorWeightMax = a.getFloat([email protected]_majorWeightMax
                                  , 0.0f);
     mMinorWeightMax = a.getFloat([email protected]_minorWeightMax
                                  , 0.0f);
     a.recycle();
 }
Пример #5
0
 public OvershootInterpolator(android.content.Context context, android.util.AttributeSet
                              attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.OvershootInterpolator);
     mTension = a.getFloat([email protected]_tension
                           , 2.0f);
     a.recycle();
 }
Пример #6
0
 public DecelerateInterpolator(android.content.Context context, android.util.AttributeSet
                               attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.DecelerateInterpolator);
     mFactor = a.getFloat([email protected]_factor,
                          1.0f);
     a.recycle();
 }
Пример #7
0
 public CycleInterpolator(android.content.Context context, android.util.AttributeSet
                          attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.CycleInterpolator);
     mCycles = a.getFloat([email protected]_cycles, 1.0f
                          );
     a.recycle();
 }
Пример #8
0
 /// <summary>Constructor used when a RotateAnimation is loaded from a resource.</summary>
 /// <remarks>Constructor used when a RotateAnimation is loaded from a resource.</remarks>
 /// <param name="context">Application context to use</param>
 /// <param name="attrs">Attribute set from which to read values</param>
 public RotateAnimation(android.content.Context context, android.util.AttributeSet
                        attrs) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.RotateAnimation);
     mFromDegrees = a.getFloat([email protected]_fromDegrees
                               , 0.0f);
     mToDegrees = a.getFloat([email protected]_toDegrees,
                             0.0f);
     android.view.animation.Animation.Description d = android.view.animation.Animation
                                                      .Description.parseValue(a.peekValue([email protected]_pivotX
                                                                                          ));
     mPivotXType  = d.type;
     mPivotXValue = d.value;
     d            = android.view.animation.Animation.Description.parseValue(a.peekValue([email protected]
                                                                                        .styleable.RotateAnimation_pivotY));
     mPivotYType  = d.type;
     mPivotYValue = d.value;
     a.recycle();
 }
Пример #9
0
 public ToggleButton(android.content.Context context, android.util.AttributeSet attrs
                     , int defStyle) : base(context, attrs, defStyle)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.ToggleButton, defStyle, 0);
     mTextOn        = a.getText([email protected]_textOn);
     mTextOff       = a.getText([email protected]_textOff);
     mDisabledAlpha = a.getFloat([email protected]_disabledAlpha
                                 , 0.5f);
     syncTextState();
     a.recycle();
 }
Пример #10
0
 public IconMenuItemView(android.content.Context context, android.util.AttributeSet
                         attrs, int defStyle) : base(context, attrs)
 {
     if (sPrependShortcutLabel == null)
     {
         sPrependShortcutLabel = getResources().getString([email protected][email protected]_shortcut_label
                                                          );
     }
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.MenuView, defStyle, 0);
     mDisabledAlpha = a.getFloat([email protected]_itemIconDisabledAlpha
                                 , 0.8f);
     mTextAppearance = a.getResourceId([email protected]_itemTextAppearance
                                       , -1);
     mTextAppearanceContext = context;
     a.recycle();
 }
Пример #11
0
        public AbsSeekBar(android.content.Context context, android.util.AttributeSet attrs
                          , int defStyle) : base(context, attrs, defStyle)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.SeekBar, defStyle, 0);
            android.graphics.drawable.Drawable thumb = a.getDrawable([email protected]
                                                                     .SeekBar_thumb);
            setThumb(thumb);
            // will guess mThumbOffset if thumb != null...
            // ...but allow layout to override this
            int thumbOffset = a.getDimensionPixelOffset([email protected]_thumbOffset
                                                        , getThumbOffset());

            setThumbOffset(thumbOffset);
            a.recycle();
            a = context.obtainStyledAttributes(attrs, [email protected], 0,
                                               0);
            mDisabledAlpha = a.getFloat([email protected]_disabledAlpha, 0.5f
                                        );
            a.recycle();
            mScaledTouchSlop = android.view.ViewConfiguration.get(context).getScaledTouchSlop
                                   ();
        }
Пример #12
0
        /// <summary>
        /// Creates a new animation whose parameters come from the specified context and
        /// attributes set.
        /// </summary>
        /// <remarks>
        /// Creates a new animation whose parameters come from the specified context and
        /// attributes set.
        /// </remarks>
        /// <param name="context">the application environment</param>
        /// <param name="attrs">the set of attributes holding the animation parameters</param>
        /// <exception cref="android.content.res.Resources.NotFoundException"></exception>
        private static android.animation.ValueAnimator loadAnimator(android.content.Context
                                                                    context, android.util.AttributeSet attrs, android.animation.ValueAnimator anim)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.Animator);
            long duration   = a.getInt([email protected]_duration, 0);
            long startDelay = a.getInt([email protected]_startOffset, 0);
            int  valueType  = a.getInt([email protected]_valueType, VALUE_TYPE_FLOAT
                                       );

            if (anim == null)
            {
                anim = new android.animation.ValueAnimator();
            }
            android.animation.TypeEvaluator <object> evaluator = null;
            int  valueFromIndex = [email protected]_valueFrom;
            int  valueToIndex   = [email protected]_valueTo;
            bool getFloats      = (valueType == VALUE_TYPE_FLOAT);

            android.util.TypedValue tvFrom = a.peekValue(valueFromIndex);
            bool hasFrom  = (tvFrom != null);
            int  fromType = hasFrom ? tvFrom.type : 0;

            android.util.TypedValue tvTo = a.peekValue(valueToIndex);
            bool hasTo  = (tvTo != null);
            int  toType = hasTo ? tvTo.type : 0;

            if ((hasFrom && (fromType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (fromType
                                                                                           <= android.util.TypedValue.TYPE_LAST_COLOR_INT)) || (hasTo && (toType >= android.util.TypedValue
                                                                                                                                                          .TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue.TYPE_LAST_COLOR_INT
                                                                                                                                                                                     )))
            {
                // special case for colors: ignore valueType and get ints
                getFloats = false;
                anim.setEvaluator(new android.animation.ArgbEvaluator());
            }
            if (getFloats)
            {
                float valueFrom;
                float valueTo;
                if (hasFrom)
                {
                    if (fromType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueFrom = a.getDimension(valueFromIndex, 0f);
                    }
                    else
                    {
                        valueFrom = a.getFloat(valueFromIndex, 0f);
                    }
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            valueTo = a.getFloat(valueToIndex, 0f);
                        }
                        anim.setFloatValues(valueFrom, valueTo);
                    }
                    else
                    {
                        anim.setFloatValues(valueFrom);
                    }
                }
                else
                {
                    if (toType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueTo = a.getDimension(valueToIndex, 0f);
                    }
                    else
                    {
                        valueTo = a.getFloat(valueToIndex, 0f);
                    }
                    anim.setFloatValues(valueTo);
                }
            }
            else
            {
                int valueFrom;
                int valueTo;
                if (hasFrom)
                {
                    if (fromType == android.util.TypedValue.TYPE_DIMENSION)
                    {
                        valueFrom = (int)a.getDimension(valueFromIndex, 0f);
                    }
                    else
                    {
                        if ((fromType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (fromType <= android.util.TypedValue
                                                                                           .TYPE_LAST_COLOR_INT))
                        {
                            valueFrom = a.getColor(valueFromIndex, 0);
                        }
                        else
                        {
                            valueFrom = a.getInt(valueFromIndex, 0);
                        }
                    }
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = (int)a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            if ((toType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue
                                                                                             .TYPE_LAST_COLOR_INT))
                            {
                                valueTo = a.getColor(valueToIndex, 0);
                            }
                            else
                            {
                                valueTo = a.getInt(valueToIndex, 0);
                            }
                        }
                        anim.setIntValues(valueFrom, valueTo);
                    }
                    else
                    {
                        anim.setIntValues(valueFrom);
                    }
                }
                else
                {
                    if (hasTo)
                    {
                        if (toType == android.util.TypedValue.TYPE_DIMENSION)
                        {
                            valueTo = (int)a.getDimension(valueToIndex, 0f);
                        }
                        else
                        {
                            if ((toType >= android.util.TypedValue.TYPE_FIRST_COLOR_INT) && (toType <= android.util.TypedValue
                                                                                             .TYPE_LAST_COLOR_INT))
                            {
                                valueTo = a.getColor(valueToIndex, 0);
                            }
                            else
                            {
                                valueTo = a.getInt(valueToIndex, 0);
                            }
                        }
                        anim.setIntValues(valueTo);
                    }
                }
            }
            anim.setDuration(duration);
            anim.setStartDelay(startDelay);
            if (a.hasValue([email protected]_repeatCount))
            {
                anim.setRepeatCount(a.getInt([email protected]_repeatCount,
                                             0));
            }
            if (a.hasValue([email protected]_repeatMode))
            {
                anim.setRepeatMode(a.getInt([email protected]_repeatMode, android.animation.ValueAnimator
                                            .RESTART));
            }
            if (evaluator != null)
            {
                anim.setEvaluator(evaluator);
            }
            int resID = a.getResourceId([email protected]_interpolator,
                                        0);

            if (resID > 0)
            {
                anim.setInterpolator(android.view.animation.AnimationUtils.loadInterpolator(context
                                                                                            , resID));
            }
            a.recycle();
            return(anim);
        }
Пример #13
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.RotateDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            android.util.TypedValue tv = a.peekValue([email protected]_pivotX
                                                     );
            bool  pivotXRel;
            float pivotX;

            if (tv == null)
            {
                pivotXRel = true;
                pivotX    = 0.5f;
            }
            else
            {
                pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
                pivotX    = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
            }
            tv = a.peekValue([email protected]_pivotY);
            bool  pivotYRel;
            float pivotY;

            if (tv == null)
            {
                pivotYRel = true;
                pivotY    = 0.5f;
            }
            else
            {
                pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION;
                pivotY    = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat();
            }
            float fromDegrees = a.getFloat([email protected]_fromDegrees
                                           , 0.0f);
            float toDegrees = a.getFloat([email protected]_toDegrees
                                         , 360.0f);
            int res = a.getResourceId([email protected]_drawable,
                                      0);

            android.graphics.drawable.Drawable drawable = null;
            if (res > 0)
            {
                drawable = r.getDrawable(res);
            }
            a.recycle();
            int outerDepth = parser.getDepth();
            int type;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if ((drawable = android.graphics.drawable.Drawable.createFromXmlInner(r, parser,
                                                                                      attrs)) == null)
                {
                    android.util.Log.w("drawable", "Bad element under <rotate>: " + parser.getName());
                }
            }
            if (drawable == null)
            {
                android.util.Log.w("drawable", "No drawable specified for <rotate>");
            }
            mState.mDrawable    = drawable;
            mState.mPivotXRel   = pivotXRel;
            mState.mPivotX      = pivotX;
            mState.mPivotYRel   = pivotYRel;
            mState.mPivotY      = pivotY;
            mState.mFromDegrees = mState.mCurrentDegrees = fromDegrees;
            mState.mToDegrees   = toDegrees;
            if (drawable != null)
            {
                drawable.setCallback(this);
            }
        }