예제 #1
0
 /// <summary>Constructor used when an AnimationSet is loaded from a resource.</summary>
 /// <remarks>Constructor used when an AnimationSet 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 AnimationSet(android.content.Context context, android.util.AttributeSet attrs
                     ) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.AnimationSet);
     setFlag(PROPERTY_SHARE_INTERPOLATOR_MASK, a.getBoolean([email protected]
                                                            .AnimationSet_shareInterpolator, true));
     init();
     if (context.getApplicationInfo().targetSdkVersion >= android.os.Build.VERSION_CODES
         .ICE_CREAM_SANDWICH)
     {
         if (a.hasValue([email protected]_duration))
         {
             mFlags |= PROPERTY_DURATION_MASK;
         }
         if (a.hasValue([email protected]_fillBefore))
         {
             mFlags |= PROPERTY_FILL_BEFORE_MASK;
         }
         if (a.hasValue([email protected]_fillAfter))
         {
             mFlags |= PROPERTY_FILL_AFTER_MASK;
         }
         if (a.hasValue([email protected]_repeatMode))
         {
             mFlags |= PROPERTY_REPEAT_MODE_MASK;
         }
         if (a.hasValue([email protected]_startOffset))
         {
             mFlags |= PROPERTY_START_OFFSET_MASK;
         }
     }
     a.recycle();
 }
예제 #2
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;
        }
예제 #3
0
        public ViewAnimator(android.content.Context context, android.util.AttributeSet attrs
                            ) : base(context, attrs)
        {
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.ViewAnimator);
            int resource = a.getResourceId([email protected]_inAnimation
                                           , 0);

            if (resource > 0)
            {
                setInAnimation(context, resource);
            }
            resource = a.getResourceId([email protected]_outAnimation
                                       , 0);
            if (resource > 0)
            {
                setOutAnimation(context, resource);
            }
            bool flag = a.getBoolean([email protected]_animateFirstView
                                     , true);

            setAnimateFirstView(flag);
            a.recycle();
            initViewAnimator(context, attrs);
        }
예제 #4
0
        public ImageView(android.content.Context context, android.util.AttributeSet attrs
                         , int defStyle) : base(context, attrs, defStyle)
        {
            initImageView();
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.ImageView, defStyle, 0);
            android.graphics.drawable.Drawable d = a.getDrawable([email protected]
                                                                 .ImageView_src);
            if (d != null)
            {
                setImageDrawable(d);
            }
            mBaselineAlignBottom = a.getBoolean([email protected]_baselineAlignBottom
                                                , false);
            mBaseline = a.getDimensionPixelSize([email protected]_baseline
                                                , -1);
            setAdjustViewBounds(a.getBoolean([email protected]_adjustViewBounds
                                             , false));
            setMaxWidth(a.getDimensionPixelSize([email protected]_maxWidth
                                                , int.MaxValue));
            setMaxHeight(a.getDimensionPixelSize([email protected]_maxHeight
                                                 , int.MaxValue));
            int index = a.getInt([email protected]_scaleType, -1);

            if (index >= 0)
            {
                setScaleType(sScaleTypeArray[index]);
            }
            int tint = a.getInt([email protected]_tint, 0);

            if (tint != 0)
            {
                setColorFilter(tint);
            }
            int alpha = a.getInt([email protected]_drawableAlpha, 255);

            if (alpha != 255)
            {
                setAlpha(alpha);
            }
            mCropToPadding = a.getBoolean([email protected]_cropToPadding
                                          , false);
            a.recycle();
        }
예제 #5
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.NinePatchDrawable);
            int id = a.getResourceId([email protected]_src, 0);

            if (id == 0)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <nine-patch> requires a valid src attribute");
            }
            bool dither = a.getBoolean([email protected]_dither
                                       , DEFAULT_DITHER);

            android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory
                                                             .Options();
            if (dither)
            {
                options.inDither = false;
            }
            options.inScreenDensity = android.util.DisplayMetrics.DENSITY_DEVICE;
            android.graphics.Rect   padding = new android.graphics.Rect();
            android.graphics.Bitmap bitmap  = null;
            try
            {
                android.util.TypedValue value = new android.util.TypedValue();
                java.io.InputStream     @is   = r.openRawResource(id, value);
                bitmap = android.graphics.BitmapFactory.decodeResourceStream(r, value, @is, padding
                                                                             , options);
                @is.close();
            }
            catch (System.IO.IOException)
            {
            }
            // Ignore
            if (bitmap == null)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <nine-patch> requires a valid src attribute");
            }
            else
            {
                if (bitmap.getNinePatchChunk() == null)
                {
                    throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                    ": <nine-patch> requires a valid 9-patch source image");
                }
            }
            setNinePatchState(new android.graphics.drawable.NinePatchDrawable.NinePatchState(
                                  new android.graphics.NinePatch(bitmap, bitmap.getNinePatchChunk(), "XML 9-patch"
                                                                 ), padding, dither), r);
            mNinePatchState.mTargetDensity = mTargetDensity;
            a.recycle();
        }
예제 #6
0
 public ViewFlipper(android.content.Context context, android.util.AttributeSet attrs
                    ) : base(context, attrs)
 {
     mReceiver = new _BroadcastReceiver_69(this);
     mHandler  = new _Handler_201(this);
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.ViewFlipper);
     mFlipInterval = a.getInt([email protected]_flipInterval,
                              DEFAULT_INTERVAL);
     mAutoStart = a.getBoolean([email protected]_autoStart, false
                               );
     a.recycle();
 }
예제 #7
0
 public FrameLayout(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.FrameLayout, defStyle, 0);
     mForegroundGravity = a.getInt([email protected]_foregroundGravity
                                   , mForegroundGravity);
     android.graphics.drawable.Drawable d = a.getDrawable([email protected]
                                                          .FrameLayout_foreground);
     if (d != null)
     {
         setForeground(d);
     }
     if (a.getBoolean([email protected]_measureAllChildren, false
                      ))
     {
         setMeasureAllChildren(true);
     }
     mForegroundInPadding = a.getBoolean([email protected]_foregroundInsidePadding
                                         , true);
     a.recycle();
 }
예제 #8
0
 public ListMenuItemView(android.content.Context context, android.util.AttributeSet
                         attrs, int defStyle) : base(context, attrs)
 {
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.MenuView, defStyle, 0);
     mBackground = a.getDrawable([email protected]_itemBackground
                                 );
     mTextAppearance = a.getResourceId([email protected]_itemTextAppearance
                                       , -1);
     mPreserveIconSpacing = a.getBoolean([email protected]_preserveIconSpacing
                                         , false);
     mTextAppearanceContext = context;
     a.recycle();
 }
예제 #9
0
 public TabWidget(android.content.Context context, android.util.AttributeSet attrs
                  , int defStyle) : base(context, attrs, defStyle)
 {
     // This value will be set to 0 as soon as the first tab is added to TabHost.
     // When positive, the widths and heights of tabs will be imposed so that they fit in parent
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.TabWidget, defStyle, 0);
     setStripEnabled(a.getBoolean(android.R.styleable.TabWidget_tabStripEnabled, true)
                     );
     setLeftStripDrawable(a.getDrawable(android.R.styleable.TabWidget_tabStripLeft));
     setRightStripDrawable(a.getDrawable(android.R.styleable.TabWidget_tabStripRight));
     a.recycle();
     initTabWidget();
 }
예제 #10
0
 public AdapterViewFlipper(android.content.Context context, android.util.AttributeSet
                           attrs) : base(context, attrs)
 {
     mReceiver = new _BroadcastReceiver_77(this);
     mHandler  = new _Handler_249(this);
     android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                       .styleable.AdapterViewFlipper);
     mFlipInterval = a.getInt([email protected]_flipInterval
                              , DEFAULT_INTERVAL);
     mAutoStart = a.getBoolean([email protected]_autoStart
                               , false);
     // A view flipper should cycle through the views
     mLoopViews = true;
     a.recycle();
 }
예제 #11
0
        public CheckedTextView(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.CheckedTextView, defStyle, 0);
            android.graphics.drawable.Drawable d = a.getDrawable([email protected]
                                                                 .CheckedTextView_checkMark);
            if (d != null)
            {
                setCheckMarkDrawable(d);
            }
            bool @checked = a.getBoolean([email protected]_checked
                                         , false);

            setChecked(@checked);
            a.recycle();
        }
예제 #12
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            int type;

            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.ScaleDrawable);
            float sw = getPercent(a, [email protected]_scaleWidth);
            float sh = getPercent(a, [email protected]_scaleHeight);
            int   g  = a.getInt([email protected]_scaleGravity, android.view.Gravity
                                .LEFT);
            bool min = a.getBoolean([email protected]_useIntrinsicSizeAsMinimum
                                    , false);

            android.graphics.drawable.Drawable dr = a.getDrawable([email protected]
                                                                  .ScaleDrawable_drawable);
            a.recycle();
            int outerDepth = parser.getDepth();

            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;
                }
                dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
            }
            if (dr == null)
            {
                throw new System.ArgumentException("No drawable specified for <scale>");
            }
            mScaleState.mDrawable              = dr;
            mScaleState.mScaleWidth            = sw;
            mScaleState.mScaleHeight           = sh;
            mScaleState.mGravity               = g;
            mScaleState.mUseIntrinsicSizeAsMin = min;
            if (dr != null)
            {
                dr.setCallback(this);
            }
        }
예제 #13
0
        /// <summary>
        /// Initialize this
        /// <see cref="ViewAnimator">ViewAnimator</see>
        /// , possibly setting
        /// <see cref="FrameLayout.setMeasureAllChildren(bool)">FrameLayout.setMeasureAllChildren(bool)
        ///     </see>
        /// based on
        /// <see cref="FrameLayout">FrameLayout</see>
        /// flags.
        /// </summary>
        private void initViewAnimator(android.content.Context context, android.util.AttributeSet
                                      attrs)
        {
            if (attrs == null)
            {
                // For compatibility, always measure children when undefined.
                mMeasureAllChildren = true;
                return;
            }
            // For compatibility, default to measure children, but allow XML
            // attribute to override.
            android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected]
                                                                              .styleable.FrameLayout);
            bool measureAllChildren = a.getBoolean([email protected]_measureAllChildren
                                                   , true);

            setMeasureAllChildren(measureAllChildren);
            a.recycle();
        }
예제 #14
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.ShapeDrawable);
            int color = mShapeState.mPaint.getColor();

            color = a.getColor([email protected]_color, color);
            mShapeState.mPaint.setColor(color);
            bool dither = a.getBoolean([email protected]_dither, false
                                       );

            mShapeState.mPaint.setDither(dither);
            setIntrinsicWidth((int)a.getDimension([email protected]_width
                                                  , 0f));
            setIntrinsicHeight((int)a.getDimension([email protected]_height
                                                   , 0f));
            a.recycle();
            int type;
            int outerDepth = parser.getDepth();

            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;
                }
                string name = parser.getName();
                // call our subclass
                if (!inflateTag(name, r, parser, attrs))
                {
                    android.util.Log.w("drawable", "Unknown element: " + name + " for ShapeDrawable "
                                       + this);
                }
            }
        }
예제 #15
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.AnimationDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            mAnimationState.setVariablePadding(a.getBoolean([email protected]_variablePadding
                                                            , false));
            mAnimationState.mOneShot = a.getBoolean([email protected]_oneshot
                                                    , false);
            a.recycle();
            int type;
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                a = r.obtainAttributes(attrs, [email protected]
                                       );
                int duration = a.getInt([email protected]_duration
                                        , -1);
                if (duration < 0)
                {
                    throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                    ": <item> tag requires a 'duration' attribute");
                }
                int drawableRes = a.getResourceId([email protected]_drawable
                                                  , 0);
                a.recycle();
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    // Empty
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or child tag" + " defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                mAnimationState.addFrame(dr, duration);
                if (dr != null)
                {
                    dr.setCallback(this);
                }
            }
            setFrame(0, true, false);
        }
예제 #16
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.StateListDrawable);
            base.inflateWithAttributes(r, parser, a, [email protected]_visible
                                       );
            mStateListState.setVariablePadding(a.getBoolean([email protected]_variablePadding
                                                            , false));
            mStateListState.setConstantSize(a.getBoolean([email protected]_constantSize
                                                         , false));
            mStateListState.setEnterFadeDuration(a.getInt([email protected]_enterFadeDuration
                                                          , 0));
            mStateListState.setExitFadeDuration(a.getInt([email protected]_exitFadeDuration
                                                         , 0));
            setDither(a.getBoolean([email protected]_dither, DEFAULT_DITHER
                                   ));
            a.recycle();
            int type;
            int innerDepth = parser.getDepth() + 1;
            int depth;

            while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT &&
                   ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG
                   ))
            {
                if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                {
                    continue;
                }
                if (depth > innerDepth || !parser.getName().Equals("item"))
                {
                    continue;
                }
                int   drawableRes = 0;
                int   i;
                int   j        = 0;
                int   numAttrs = attrs.getAttributeCount();
                int[] states   = new int[numAttrs];
                for (i = 0; i < numAttrs; i++)
                {
                    int stateResId = attrs.getAttributeNameResource(i);
                    if (stateResId == 0)
                    {
                        break;
                    }
                    if (stateResId == [email protected])
                    {
                        drawableRes = attrs.getAttributeResourceValue(i, 0);
                    }
                    else
                    {
                        states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
                    }
                }
                states = android.util.StateSet.trimStateSet(states, j);
                android.graphics.drawable.Drawable dr;
                if (drawableRes != 0)
                {
                    dr = r.getDrawable(drawableRes);
                }
                else
                {
                    while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT)
                    {
                    }
                    if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG)
                    {
                        throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                        ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable"
                                                                        );
                    }
                    dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs);
                }
                mStateListState.addStateSet(states, dr);
            }
            onStateChange(getState());
        }
예제 #17
0
        public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser
                                     parser, android.util.AttributeSet attrs)
        {
            base.inflate(r, parser, attrs);
            android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected].
                                                                  styleable.BitmapDrawable);
            int id = a.getResourceId([email protected]_src, 0);

            if (id == 0)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <bitmap> requires a valid src attribute");
            }
            android.graphics.Bitmap bitmap = android.graphics.BitmapFactory.decodeResource(r,
                                                                                           id);
            if (bitmap == null)
            {
                throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() +
                                                                ": <bitmap> requires a valid src attribute");
            }
            mBitmapState.mBitmap = bitmap;
            setBitmap(bitmap);
            setTargetDensity(r.getDisplayMetrics());
            android.graphics.Paint paint = mBitmapState.mPaint;
            paint.setAntiAlias(a.getBoolean([email protected]_antialias
                                            , paint.isAntiAlias()));
            paint.setFilterBitmap(a.getBoolean([email protected]_filter
                                               , paint.isFilterBitmap()));
            paint.setDither(a.getBoolean([email protected]_dither,
                                         paint.isDither()));
            setGravity(a.getInt([email protected]_gravity, android.view.Gravity
                                .FILL));
            int tileMode = a.getInt([email protected]_tileMode, -1
                                    );

            if (tileMode != -1)
            {
                switch (tileMode)
                {
                case 0:
                {
                    setTileModeXY(android.graphics.Shader.TileMode.CLAMP, android.graphics.Shader.TileMode
                                  .CLAMP);
                    break;
                }

                case 1:
                {
                    setTileModeXY(android.graphics.Shader.TileMode.REPEAT, android.graphics.Shader.TileMode
                                  .REPEAT);
                    break;
                }

                case 2:
                {
                    setTileModeXY(android.graphics.Shader.TileMode.MIRROR, android.graphics.Shader.TileMode
                                  .MIRROR);
                    break;
                }
                }
            }
            a.recycle();
        }