示例#1
0
        /// <summary>
        /// Sets the switch text color, size, style, hint color, and highlight color
        /// from the specified TextAppearance resource.
        /// </summary>
        /// <remarks>
        /// Sets the switch text color, size, style, hint color, and highlight color
        /// from the specified TextAppearance resource.
        /// </remarks>
        public virtual void setSwitchTextAppearance(android.content.Context context, int
                                                    resid)
        {
            android.content.res.TypedArray appearance = context.obtainStyledAttributes(resid,
                                                                                       [email protected]);
            android.content.res.ColorStateList colors;
            int ts;

            colors = appearance.getColorStateList([email protected]_textColor
                                                  );
            if (colors != null)
            {
                mTextColors = colors;
            }
            else
            {
                // If no color set in TextAppearance, default to the view's textColor
                mTextColors = getTextColors();
            }
            ts = appearance.getDimensionPixelSize([email protected]_textSize
                                                  , 0);
            if (ts != 0)
            {
                if (ts != mTextPaint.getTextSize())
                {
                    mTextPaint.setTextSize(ts);
                    requestLayout();
                }
            }
            int typefaceIndex;
            int styleIndex;

            typefaceIndex = appearance.getInt([email protected]_typeface
                                              , -1);
            styleIndex = appearance.getInt([email protected]_textStyle
                                           , -1);
            setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
            appearance.recycle();
        }
示例#2
0
        private void init(android.content.Context context)
        {
            // Get both the scrollbar states drawables
            android.content.res.TypedArray ta = context.getTheme().obtainStyledAttributes(ATTRS
                                                                                          );
            useThumbDrawable(context, ta.getDrawable(THUMB_DRAWABLE));
            mTrackDrawable        = ta.getDrawable(TRACK_DRAWABLE);
            mOverlayDrawableLeft  = ta.getDrawable(PREVIEW_BACKGROUND_LEFT);
            mOverlayDrawableRight = ta.getDrawable(PREVIEW_BACKGROUND_RIGHT);
            mOverlayPosition      = ta.getInt(OVERLAY_POSITION, OVERLAY_FLOATING);
            mScrollCompleted      = true;
            getSectionsFromIndexer();
            mOverlaySize = context.getResources().getDimensionPixelSize([email protected]
                                                                        .fastscroll_overlay_size);
            mOverlayPos = new android.graphics.RectF();
            mScrollFade = new android.widget.FastScroller.ScrollFade(this);
            mPaint      = new android.graphics.Paint();
            mPaint.setAntiAlias(true);
            mPaint.setTextAlign(android.graphics.Paint.Align.CENTER);
            mPaint.setTextSize(mOverlaySize / 2);
            android.content.res.ColorStateList textColor = ta.getColorStateList(TEXT_COLOR);
            int textColorNormal = textColor.getDefaultColor();

            mPaint.setColor(textColorNormal);
            mPaint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE);
            // to show mOverlayDrawable properly
            if (mList.getWidth() > 0 && mList.getHeight() > 0)
            {
                onSizeChanged(mList.getWidth(), mList.getHeight(), 0, 0);
            }
            mState = STATE_NONE;
            refreshDrawableState();
            ta.recycle();
            mScaledTouchSlop = android.view.ViewConfiguration.get(context).getScaledTouchSlop
                                   ();
            mMatchDragPosition = context.getApplicationInfo().targetSdkVersion >= android.os.Build
                                 .VERSION_CODES.HONEYCOMB;
            setScrollbarPosition(mList.getVerticalScrollbarPosition());
        }