android.util.TypedValue#getFloat ( )源码实例Demo

下面列出了android.util.TypedValue#getFloat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TwistyTimer   文件: ChromaDialogFixed.java
private void measureLayout(AlertDialog ad) {
    int widthMultiplier = getResources().getConfiguration()
            .orientation == Configuration.ORIENTATION_LANDSCAPE
            ? 2
            : 1;

    TypedValue typedValue = new TypedValue();
    getResources().getValue(R.dimen.chroma_dialog_height_multiplier, typedValue, true);
    float heightMultiplier = typedValue.getFloat();

    int height = getResources().getConfiguration()
            .orientation == Configuration.ORIENTATION_LANDSCAPE
            ? (int) (ad.getContext().getResources().getDisplayMetrics().heightPixels * heightMultiplier)
            : WindowManager.LayoutParams.WRAP_CONTENT;

    int width = getResources().getDimensionPixelSize(R.dimen.chroma_dialog_width) * widthMultiplier;

    ad.getWindow().setLayout(width, height);
}
 
源代码2 项目: justaline-android   文件: BrushSelector.java
private void onBrushSizeSelected(AppSettings.LineWidth lineWidth) {
    mSelectedLineWidth = lineWidth;

    TypedValue outValue = new TypedValue();

    switch (lineWidth) {
        case SMALL:
            getResources().getValue(R.dimen.brush_scale_small, outValue, true);
            mSelectedBrush = SMALL_BRUSH;
            break;
        case MEDIUM:
            getResources().getValue(R.dimen.brush_scale_medium, outValue, true);
            mSelectedBrush = MEDIUM_BRUSH;
            break;
        default:
        case LARGE:
            getResources().getValue(R.dimen.brush_scale_large, outValue, true);
            mSelectedBrush = LARGE_BRUSH;
            break;
    }

    float scale = outValue.getFloat();

    mSelectedSizeIndicator.animate().scaleX(scale).scaleY(scale);
}
 
源代码3 项目: ticdesign   文件: ScalableTextView.java
@TargetApi(21)
public ScalableTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ScalableTextView, defStyleAttr, defStyleRes);

    float defaultFactor;
    if (isInEditMode()) {
        defaultFactor = 0;
    } else {
        TypedValue typedValue = new TypedValue();
        getResources().getValue(R.integer.design_factor_title_scale, typedValue, true);
        defaultFactor = typedValue.getFloat();
    }
    mScaleFactor = a.getFloat(R.styleable.ScalableTextView_tic_scaleFactor, defaultFactor);

    a.recycle();
}
 
源代码4 项目: ProjectX   文件: OverflowListView.java
OverflowListView(Context context) {
    super(context);
    setWillNotDraw(false);
    final Resources resources = context.getResources();
    final TypedValue outValue = new TypedValue();
    resources.getValue(R.dimen.floatingActionModeOverflowItemMaxShowCount, outValue, true);
    float count = outValue.getFloat();
    int overflowMinimumWidth = resources.getDimensionPixelOffset(
            R.dimen.floatingActionModeOverflowItemMinimumWidth);
    @SuppressLint("CustomViewStyleable") final TypedArray custom =
            context.obtainStyledAttributes(R.styleable.FloatingActionMode);
    count = custom.getFloat(
            R.styleable.FloatingActionMode_floatingActionModeOverflowItemMaxShowCount, count);
    overflowMinimumWidth = custom.getDimensionPixelOffset(
            R.styleable.FloatingActionMode_floatingActionModeOverflowItemMinimumWidth,
            overflowMinimumWidth);
    custom.recycle();
    setItemMinimumWidth(overflowMinimumWidth);
    mMaxHeight = (int) (mCalculator.getSize() * count);
    mCornerCrop.setFillType(Path.FillType.EVEN_ODD);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    mCropPath.setFillType(Path.FillType.EVEN_ODD);
    setOnItemClickListener(this);
}
 
/**
 * Constructor
 *
 * @param context        context
 * @param boundedOverlay bounded overlay
 * @param featureTiles   feature tiles
 * @since 1.2.5
 */
public FeatureOverlayQuery(Context context, BoundedOverlay boundedOverlay, FeatureTiles featureTiles) {
    this.boundedOverlay = boundedOverlay;
    this.featureTiles = featureTiles;

    Resources resources = context.getResources();

    // Get the screen percentage to determine when a feature is clicked
    TypedValue screenPercentage = new TypedValue();
    resources.getValue(R.dimen.map_feature_overlay_click_screen_percentage, screenPercentage, true);
    screenClickPercentage = screenPercentage.getFloat();

    maxFeaturesInfo = resources.getBoolean(R.bool.map_feature_overlay_max_features_info);
    featuresInfo = resources.getBoolean(R.bool.map_feature_overlay_features_info);

    FeatureDao featureDao = featureTiles.getFeatureDao();
    featureInfoBuilder = new FeatureInfoBuilder(context, featureDao);
}
 
源代码6 项目: pe-protector-moe   文件: Rotate3dAnimation.java
Description parseValue(TypedValue value) {
    Description d = new Description();
    if (value == null) {
        d.type = ABSOLUTE;
        d.value = 0;
    } else {
        if (value.type == TypedValue.TYPE_FRACTION) {
            d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
                    TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
                    RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
            d.value = TypedValue.complexToFloat(value.data);
            return d;
        } else if (value.type == TypedValue.TYPE_FLOAT) {
            d.type = ABSOLUTE;
            d.value = value.getFloat();
            return d;
        } else if (value.type >= TypedValue.TYPE_FIRST_INT &&
                value.type <= TypedValue.TYPE_LAST_INT) {
            d.type = ABSOLUTE;
            d.value = value.data;
            return d;
        }
    }

    d.type = ABSOLUTE;
    d.value = 0.0f;

    return d;
}
 
源代码7 项目: indeterminate-checkbox   文件: Utils.java
private static float resolveFloat(Context context, @AttrRes int attr, float defaultValue) {
    TypedValue val = new TypedValue();
    if (context.getTheme().resolveAttribute(attr, val, true)) {
        return val.getFloat();
    } else {
        return defaultValue;
    }
}
 
源代码8 项目: LeanbackTvSample   文件: MyFocusHighlightHelper.java
void lazyInit(View view) {
    if (!mInitialized) {
        Resources res = view.getResources();
        TypedValue value = new TypedValue();
        res.getValue(R.dimen.lb_browse_header_select_scale, value, true);
        mSelectScale = value.getFloat();
        res.getValue(R.dimen.lb_browse_header_select_duration, value, true);
        mDuration = value.data;
        mInitialized = true;
    }
}
 
源代码9 项目: simpletask-android   文件: Utils.java
private static float resolveFloat(Context context, @AttrRes int attr, float defaultValue) {
    TypedValue val = new TypedValue();
    if (context.getTheme().resolveAttribute(attr, val, true)) {
        return val.getFloat();
    } else {
        return defaultValue;
    }
}
 
源代码10 项目: AndroidSchool   文件: MoviesActivity.java
@NonNull
private MoviesAdapter createAdapter() {
    TypedValue typedValue = new TypedValue();
    getResources().getValue(R.dimen.rows_count, typedValue, true);
    float rowsCount = typedValue.getFloat();
    int actionBarHeight = getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true)
            ? TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics())
            : 0;
    int imageHeight = (int) ((getResources().getDisplayMetrics().heightPixels - actionBarHeight) / rowsCount);

    int columns = getResources().getInteger(R.integer.columns_count);
    int imageWidth = getResources().getDisplayMetrics().widthPixels / columns;

    return new MoviesAdapter(imageHeight, imageWidth, this);
}
 
源代码11 项目: BlackList   文件: Utils.java
/**
 * Scales passed view with passed dimension on Tablets only
 */
public static void scaleViewOnTablet(Context context, View view, @DimenRes int dimenRes) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        boolean isTablet = context.getResources().getBoolean(R.bool.isTablet);
        if (isTablet) {
            TypedValue outValue = new TypedValue();
            context.getResources().getValue(dimenRes, outValue, true);
            float scale = outValue.getFloat();
            view.setScaleX(scale);
            view.setScaleY(scale);
        }
    }
}
 
源代码12 项目: LockPattern   文件: LockPatternView.java
private void initDefaultFloats(){
    TypedValue tv = new TypedValue();
    getResources().getValue(R.dimen.dotAnimScaleMax, tv, true);
    mDotAnimationScaleMax = tv.getFloat();

    getResources().getValue(R.dimen.dotAnimScaleNormal, tv, true);
    mDotAnimationScaleNormal = tv.getFloat();
}
 
源代码13 项目: StackOverView   文件: OverviewConfiguration.java
/** Updates the state, given the specified context */
void update(Context context) {
    Resources res = context.getResources();
    DisplayMetrics dm = res.getDisplayMetrics();

    // Insets
    displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);

    // Task stack
    taskStackScrollDuration =
            res.getInteger(R.integer.recents_animate_task_stack_scroll_duration);

    //获取dimen资源值
    TypedValue widthPaddingPctValue = new TypedValue();
    res.getValue(R.dimen.recents_stack_width_padding_percentage, widthPaddingPctValue, true);
    taskStackWidthPaddingPct = widthPaddingPctValue.getFloat();

    //获取dimen资源值
    TypedValue stackOverscrollPctValue = new TypedValue();
    res.getValue(R.dimen.recents_stack_overscroll_percentage, stackOverscrollPctValue, true);
    taskStackOverscrollPct = stackOverscrollPctValue.getFloat();

    taskStackMaxDim = res.getInteger(R.integer.recents_max_task_stack_view_dim);
    taskStackTopPaddingPx = res.getDimensionPixelSize(R.dimen.recents_stack_top_padding);

    // Task view animation and styles
    taskViewEnterFromHomeDelay =
            res.getInteger(R.integer.recents_animate_task_enter_from_home_delay);
    taskViewEnterFromHomeDuration =
            res.getInteger(R.integer.recents_animate_task_enter_from_home_duration);
    taskViewEnterFromHomeStaggerDelay =
            res.getInteger(R.integer.recents_animate_task_enter_from_home_stagger_delay);
    taskViewRemoveAnimDuration =
            res.getInteger(R.integer.recents_animate_task_view_remove_duration);
    taskViewRemoveAnimTranslationXPx =
            res.getDimensionPixelSize(R.dimen.recents_task_view_remove_anim_translation_x);
    taskViewTranslationZMinPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_min);
    taskViewTranslationZMaxPx = res.getDimensionPixelSize(R.dimen.recents_task_view_z_max);
}
 
源代码14 项目: UIWidget   文件: ResourceUtil.java
public float getAttrFloat(int attrRes, float def) {
    float result = def;
    try {
        TypedValue typedValue = new TypedValue();
        mContext.getTheme().resolveAttribute(attrRes, typedValue, true);
        result = typedValue.getFloat();
    } catch (Exception e) {

    }
    return result == 0 ? def : result;
}
 
源代码15 项目: SublimePicker   文件: ButtonLayout.java
void initialize() {
    Context context = getContext();
    final Resources res = getResources();

    final TypedArray a = context.obtainStyledAttributes(R.styleable.ButtonLayout);

    if (SUtils.isApi_17_OrHigher()) {
        setLayoutDirection(LAYOUT_DIRECTION_LOCALE);
    }

    setOrientation(HORIZONTAL);
    setGravity(Gravity.BOTTOM);

    setPadding(res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_start),
            res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_top),
            res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_end),
            res.getDimensionPixelSize(R.dimen.sp_button_bar_padding_bottom));

    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.sublime_button_panel_layout, this, true);

    mSwitcherButton = (Button) findViewById(R.id.buttonSwitcher);

    Button bPositive = (Button) findViewById(R.id.buttonPositive);
    Button bNegative = (Button) findViewById(R.id.buttonNegative);

    ImageView ivPositive = (ImageView) findViewById(R.id.imageViewPositive);
    ImageView ivNegative = (ImageView) findViewById(R.id.imageViewNegative);

    try {
        // obtain float value held by android.R.attr.disabledAlpha
        TypedValue typedValueDisabledAlpha = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.disabledAlpha,
                typedValueDisabledAlpha, true);

        // defaults to 0.5 ~ 122/255
        mDisabledAlpha = typedValueDisabledAlpha.type == TypedValue.TYPE_FLOAT ?
                (int) (typedValueDisabledAlpha.getFloat() * 255)
                : 122;

        // buttons or icons?
        int presentation = a.getInt(R.styleable.ButtonLayout_spPresentation, 0);

        int bgColor = a.getColor(R.styleable.ButtonLayout_spButtonBgColor,
                SUtils.COLOR_BUTTON_NORMAL);
        int pressedBgColor = a.getColor(R.styleable.ButtonLayout_spButtonPressedBgColor,
                SUtils.COLOR_CONTROL_HIGHLIGHT);

        mButtonBarBgColor = a.getColor(R.styleable.ButtonLayout_spButtonBarBgColor,
                Color.TRANSPARENT);
        SUtils.setViewBackground(mSwitcherButton,
                SUtils.createButtonBg(context, bgColor,
                        pressedBgColor));
        setBackgroundColor(mButtonBarBgColor);

        if (presentation == 0 /* mode: Button */) {
            bPositive.setVisibility(View.VISIBLE);
            bNegative.setVisibility(View.VISIBLE);

            bPositive.setText(res.getString(R.string.ok));
            bNegative.setText(res.getString(R.string.cancel));

            SUtils.setViewBackground(bPositive,
                    SUtils.createButtonBg(context, bgColor,
                            pressedBgColor));
            SUtils.setViewBackground(bNegative,
                    SUtils.createButtonBg(context, bgColor,
                            pressedBgColor));

            mPositiveButton = bPositive;
            mNegativeButton = bNegative;
        } else /* mode: ImageView */ {
            ivPositive.setVisibility(View.VISIBLE);
            ivNegative.setVisibility(View.VISIBLE);

            mIconOverlayColor = a.getColor(R.styleable.ButtonLayout_spIconColor,
                    SUtils.COLOR_ACCENT);

            ivPositive.setColorFilter(mIconOverlayColor, PorterDuff.Mode.MULTIPLY);
            ivNegative.setColorFilter(mIconOverlayColor, PorterDuff.Mode.MULTIPLY);

            SUtils.setViewBackground(ivPositive,
                    SUtils.createImageViewBg(bgColor,
                            pressedBgColor));
            SUtils.setViewBackground(ivNegative,
                    SUtils.createImageViewBg(bgColor,
                            pressedBgColor));

            mPositiveButton = ivPositive;
            mNegativeButton = ivNegative;
        }
    } finally {
        a.recycle();
    }

    // set OnClickListeners
    mPositiveButton.setOnClickListener(this);
    mNegativeButton.setOnClickListener(this);
    mSwitcherButton.setOnClickListener(this);
}
 
源代码16 项目: ticdesign   文件: CoordinatorLayout.java
public CoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    if (!isInEditMode()) {
        ThemeUtils.checkDesignTheme(context);
    }

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CoordinatorLayout,
            defStyleAttr, defStyleRes);
    final int keylineArrayRes = a.getResourceId(R.styleable.CoordinatorLayout_tic_keylines, 0);
    if (keylineArrayRes != 0) {
        final Resources res = context.getResources();
        mKeylines = res.getIntArray(keylineArrayRes);
        final float density = res.getDisplayMetrics().density;
        final int count = mKeylines.length;
        for (int i = 0; i < count; i++) {
            mKeylines[i] *= density;
        }
    }
    mStatusBarBackground = a.getDrawable(R.styleable.CoordinatorLayout_tic_statusBarBackground);

    int effect = a.getInt(R.styleable.CoordinatorLayout_tic_overScrollEffect, OverScrollEffect.BOUNCE.ordinal());
    mOverScrollEffect = OverScrollEffect.values()[effect];

    a.recycle();

    super.setOnHierarchyChangeListener(new HierarchyChangeListener());

    mScrollBarHelper = new ScrollBarHelper(context, attrs, defStyleAttr);
    mViewScrollingStatusAccessor = new ViewScrollingStatusAccessor();

    if (mEdgeGlowTop == null) {
        mEdgeGlowTop = new ClassicEdgeEffect(context);
        mEdgeGlowBottom = new ClassicEdgeEffect(context);
    }

    mSystemShapeUpdated = false;
    setupForWindowInsets();

    if (isInEditMode()) {
        mOverScrollOffsetFactor = 0.5f;
        mOverScrollOffsetLimit = Integer.MAX_VALUE;
    } else {
        TypedValue typedValue = new TypedValue();
        getResources().getValue(R.integer.design_factor_over_scroll_bounce, typedValue, true);
        mOverScrollOffsetFactor = typedValue.getFloat();
        mOverScrollOffsetLimit = getResources().getDimensionPixelOffset(R.dimen.design_over_scroll_limit);
    }

    setWillNotDraw(false);
}
 
@SuppressLint("LongLogTag")
    private void initThemeVars(Resources.Theme theme) {
        DisplayMetrics dm = getResources().getDisplayMetrics();

        // init theme params
        TypedValue typedValue = new TypedValue();

        theme.resolveAttribute(R.attr.colorPrimary, typedValue, true);
        primaryColor = typedValue.data;

        theme.resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
        primaryDarkColor = typedValue.data;

        theme.resolveAttribute(R.attr.autoDarkStatusBar, typedValue, true);
        autoDarkStatusbar = typedValue.data != 0;

        theme.resolveAttribute(R.attr.uniqueToolbarColor, typedValue, false);
        uniqueToolbarColor = typedValue.data != 0;

        theme.resolveAttribute(R.attr.drawerColor, typedValue, true);
        drawerColor = typedValue.data;

       /* theme.resolveAttribute(R.attr.dividerColor, typedValue, true);
        dividerColor = typedValue.data;
*/
        theme.resolveAttribute(R.attr.drawerWidth, typedValue, true);
        drawerWidth = (int) typedValue.getDimension(dm);
        //TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics());
        if (drawerWidth < 0) {
            drawerWidth = 1;
        } else {
            setDrawerStateListener(new DefaultDrawerListener(drawerWidth));
        }

        theme.resolveAttribute(R.attr.dividerStrokeWidth, typedValue, true);
        dividerStrokeThickness = (int) typedValue.getDimension(dm);
        //TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics());
        if (dividerStrokeThickness < 0) {
            dividerStrokeThickness = 1;
        }

        theme.resolveAttribute(R.attr.belowToolbar, typedValue, true);
        belowToolbar = typedValue.data != 0;

        theme.resolveAttribute(R.attr.multipaneSupport, typedValue, false);
        multiPaneSupport = typedValue.data != 0;

        theme.resolveAttribute(R.attr.titleColor, typedValue, true);
        theme.resolveAttribute(R.attr.headItemStyle, typedValue, true);

        // Values of the NavigationDrawer
        TypedArray valuesNavigationDrawer = theme.obtainStyledAttributes(typedValue.resourceId, R.styleable.MaterialNavigationDrawer);
        dividerColor = valuesNavigationDrawer.getDrawable(R.styleable.MaterialNavigationDrawer_dividerColor);

        // Values of the Account
        TypedArray values = theme.obtainStyledAttributes(typedValue.resourceId, R.styleable.MaterialHeadItem);

        theme.resolveAttribute(R.attr.actionBarOverlay, typedValue, false);
        actionBarOverlay = typedValue.data != 0;

        theme.resolveAttribute(R.attr.actionBarOverlayAlpha, typedValue, false);
        actionBarOverlayAlpha = typedValue.getFloat();

        //actionbar style customization
        theme.resolveAttribute(R.attr.drawerActionBarStyle, typedValue, true);
        drawerActionBarStyle = typedValue.data;
    }
 
public static float getDisabledAlpha(Context context) {
    final TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
    return outValue.getFloat();
}
 
源代码19 项目: geopackage-android   文件: NumberFeaturesTile.java
/**
 * Constructor
 *
 * @param context context
 */
public NumberFeaturesTile(Context context) {

    Resources resources = context.getResources();

    // Set the default text paint values
    textPaint.setColor(ContextCompat.getColor(context, R.color.number_features_tile_text_color));
    textPaint.setTextSize(resources.getDimensionPixelSize(R.dimen.number_features_tile_text_size));

    // Set the default circle paint values
    if (resources.getBoolean(R.bool.number_features_tile_circle_draw)) {
        circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        circlePaint.setStyle(Paint.Style.STROKE);
        circlePaint.setColor(ContextCompat.getColor(context, R.color.number_features_tile_circle_color));
        TypedValue circleStrokeWidth = new TypedValue();
        resources.getValue(R.dimen.number_features_tile_circle_stroke_width,
                circleStrokeWidth, true);
        circlePaint.setStrokeWidth(circleStrokeWidth.getFloat());
    }

    // Set the default circle fill paint values
    if (resources.getBoolean(R.bool.number_features_tile_circle_fill_draw)) {
        circleFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        circleFillPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        circleFillPaint.setColor(ContextCompat.getColor(context, R.color.number_features_tile_circle_fill_color));
    }

    // Set the default tile border paint values
    if (resources.getBoolean(R.bool.number_features_tile_border_draw)) {
        tileBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        tileBorderPaint.setStyle(Paint.Style.STROKE);
        tileBorderPaint.setColor(ContextCompat.getColor(context, R.color.number_features_tile_border_color));
        TypedValue tileBorderStrokeWidth = new TypedValue();
        resources.getValue(R.dimen.number_features_tile_border_stroke_width,
                tileBorderStrokeWidth, true);
        tileBorderPaint.setStrokeWidth(tileBorderStrokeWidth.getFloat());
    }

    // Set the default tile fill paint values
    if (resources.getBoolean(R.bool.number_features_tile_fill_draw)) {
        tileFillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        tileFillPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        tileFillPaint.setColor(ContextCompat.getColor(context, R.color.number_features_tile_fill_color));
    }

    // Set the default circle padding percentage
    TypedValue circlePadding = new TypedValue();
    resources.getValue(R.dimen.number_features_tile_circle_padding_percentage,
            circlePadding, true);
    circlePaddingPercentage = circlePadding.getFloat();

    // Set the default draw unindexed tiles value
    drawUnindexedTiles = resources.getBoolean(R.bool.number_features_tile_unindexed_draw);
}
 
源代码20 项目: DateTimePicker   文件: RadialTimePickerView.java
public RadialTimePickerView(
        Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)  {
    super(context, attrs);

    applyAttributes(attrs, defStyleAttr, defStyleRes);

    // Pull disabled alpha from theme.
    final TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true);
    mDisabledAlpha = outValue.getFloat();

    mTypeface = Typeface.create("sans-serif", Typeface.NORMAL);

    mPaint[HOURS] = new Paint();
    mPaint[HOURS].setAntiAlias(true);
    mPaint[HOURS].setTextAlign(Paint.Align.CENTER);

    mPaint[MINUTES] = new Paint();
    mPaint[MINUTES].setAntiAlias(true);
    mPaint[MINUTES].setTextAlign(Paint.Align.CENTER);

    mPaintCenter.setAntiAlias(true);

    mPaintSelector[SELECTOR_CIRCLE] = new Paint();
    mPaintSelector[SELECTOR_CIRCLE].setAntiAlias(true);

    mPaintSelector[SELECTOR_DOT] = new Paint();
    mPaintSelector[SELECTOR_DOT].setAntiAlias(true);

    mPaintSelector[SELECTOR_LINE] = new Paint();
    mPaintSelector[SELECTOR_LINE].setAntiAlias(true);
    mPaintSelector[SELECTOR_LINE].setStrokeWidth(2);

    mPaintBackground.setAntiAlias(true);

    final Resources res = getResources();
    mSelectorRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_radius);
    mSelectorStroke = res.getDimensionPixelSize(R.dimen.timepicker_selector_stroke);
    mSelectorDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_dot_radius);
    mCenterDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_center_dot_radius);

    mTextSize[HOURS] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_normal);
    mTextSize[MINUTES] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_normal);
    mTextSize[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_inner);

    mTextInset[HOURS] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_normal);
    mTextInset[MINUTES] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_normal);
    mTextInset[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_inner);

    mShowHours = true;
    mHoursToMinutes = HOURS;
    mIs24HourMode = false;
    mAmOrPm = AM;

    // Set up accessibility components.
    mTouchHelper = new RadialPickerTouchHelper();
    ViewCompat.setAccessibilityDelegate(this, mTouchHelper);
    //setAccessibilityDelegate(mTouchHelper);

    if(ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO){
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    /*if (getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
    }*/

    initHoursAndMinutesText();
    initData();

    // Initial values
    final Calendar calendar = Calendar.getInstance(Locale.getDefault());
    final int currentHour = calendar.get(Calendar.HOUR_OF_DAY);
    final int currentMinute = calendar.get(Calendar.MINUTE);

    setCurrentHourInternal(currentHour, false, false);
    setCurrentMinuteInternal(currentMinute, false);

    setHapticFeedbackEnabled(true);
}