android.content.res.TypedArray#getInteger()源码实例Demo

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

源代码1 项目: arcusandroid   文件: Version1EditText.java
private void initArcusStyle(Context context, AttributeSet attrs) {

        Float textSize = DEFAULT_TEXT_SIZE * getResources().getDisplayMetrics().scaledDensity;
        Integer textStyle = DARK;
        Boolean clearable = false;
        Boolean showable = false;

        TypedArray a = context.getTheme().obtainStyledAttributes(
                attrs,
                R.styleable.Version1EditText,
                0, 0);

        try {
            textSize = a.getDimension(R.styleable.Version1EditText_iet_textSize, textSize);
            textSize = textSize / getResources().getDisplayMetrics().scaledDensity;
            textStyle = a.getInteger(R.styleable.Version1EditText_iet_style, DARK); // 0 - dark / 1 - light
            clearable = a.getBoolean(R.styleable.Version1EditText_iet_clearable, clearable);
            showable = a.getBoolean(R.styleable.Version1EditText_iet_showable, showable);
        } finally {
            a.recycle();
        }

        init(textStyle, textSize, clearable, showable);
    }
 
源代码2 项目: edx-app-android   文件: ProgressWheel.java
/**
 * Parse the attributes passed to the view from the XML
 *
 * @param a the attributes to parse
 */
private void parseAttributes(TypedArray a) {
    barWidth = (int) a.getDimension(R.styleable.ProgressWheel_barWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.ProgressWheel_rimWidth, rimWidth);
    spinSpeed = (int) a.getDimension(R.styleable.ProgressWheel_spinSpeed, spinSpeed);
    barLength = (int) a.getDimension(R.styleable.ProgressWheel_progressBarLength, barLength);

    delayMillis = a.getInteger(R.styleable.ProgressWheel_delayMillis, delayMillis);
    if (delayMillis < 0) { delayMillis = 10; }

    // Only set the text if it is explicitly defined
    if (a.hasValue(R.styleable.ProgressWheel_text)) {
        setText(a.getString(R.styleable.ProgressWheel_text));
    }

    barColor = a.getColor(R.styleable.ProgressWheel_barColor, barColor);
    textColor = a.getColor(R.styleable.ProgressWheel_textColor, textColor);
    rimColor = a.getColor(R.styleable.ProgressWheel_rimColor, rimColor);
    circleColor = a.getColor(R.styleable.ProgressWheel_circleColor, circleColor);
    contourColor = a.getColor(R.styleable.ProgressWheel_contourColor, contourColor);

    textSize = (int) a.getDimension(R.styleable.ProgressWheel_textSize, textSize);
    contourSize = a.getDimension(R.styleable.ProgressWheel_contourSize, contourSize);

    a.recycle();
}
 
源代码3 项目: Oblique   文件: Config.java
public Config(Context context, AttributeSet attrs) {
    TypedArray attributes = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ObliqueView, 0, 0);
    try {
        startAngle = attributes.getFloat(R.styleable.ObliqueView_starting_slant_angle, 90f);
        endAngle = attributes.getFloat(R.styleable.ObliqueView_ending_slant_angle, 90f);
        baseColor = attributes.getColor(R.styleable.ObliqueView_basecolor, Color.TRANSPARENT);
        radius = attributes.getFloat(R.styleable.ObliqueView_radius, 0f);
        type = attributes.getInt(R.styleable.ObliqueView_type, 0);
        startColor = attributes.getColor(R.styleable.ObliqueView_startcolor, Color.TRANSPARENT);
        endColor = attributes.getColor(R.styleable.ObliqueView_endcolor, Color.TRANSPARENT);
        elevation = attributes.getFloat(R.styleable.ObliqueView_shadow_height, 0f);
        int gradientangle = attributes.getInteger(R.styleable.ObliqueView_angle, 0);
        setupAngle(gradientangle);

    } finally {
        attributes.recycle();
    }
}
 
源代码4 项目: BaseProject   文件: ShapeImageView.java
private void init(Context context, AttributeSet attrs) {
    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.ShapeImageViewStyle);
        borderWidth = array.getDimensionPixelOffset(R.styleable.ShapeImageViewStyle_siv_border_width, borderWidth);
        borderColor = array.getColor(R.styleable.ShapeImageViewStyle_siv_border_color, borderColor);
        radius = array.getDimensionPixelOffset(R.styleable.ShapeImageViewStyle_siv_radius, radius);
        pressedAlpha = array.getFloat(R.styleable.ShapeImageViewStyle_siv_pressed_alpha, pressedAlpha);
        if (pressedAlpha > 1) pressedAlpha = 1;
        pressedColor = array.getColor(R.styleable.ShapeImageViewStyle_siv_pressed_color, pressedColor);
        shapeType = array.getInteger(R.styleable.ShapeImageViewStyle_siv_shape_type, shapeType);
        array.recycle();
    }

    setClickable(shapeType != ShapeType.NONE);
    initPressedPaint();
    setDrawingCacheEnabled(true);
    setWillNotDraw(false);
}
 
源代码5 项目: FimiX8-RE   文件: X8ValueSeakBarView.java
private void readAttr(Context context, AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.X8ValueSeakBarView);
    this.accuracy = a.getInteger(R.styleable.X8ValueSeakBarView_x8_value_accuracy, 1);
    this.title = a.getString(R.styleable.X8ValueSeakBarView_x8_value_title);
    this.suffix = a.getString(R.styleable.X8ValueSeakBarView_x8_value_suffix);
    this.closeColor = a.getColor(R.styleable.X8ValueSeakBarView_x8_value_close_color, -1);
    this.openColor = a.getColor(R.styleable.X8ValueSeakBarView_x8_value_open_color, InputDeviceCompat.SOURCE_ANY);
    this.seekBarMax = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_max, 0.0f) * ((float) this.accuracy);
    this.seekBarMin = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_min, 0.0f) * ((float) this.accuracy);
    this.seekBarDefault = a.getFloat(R.styleable.X8ValueSeakBarView_x8_value_seekbar_default, 0.0f);
    this.isFloat = a.getBoolean(R.styleable.X8ValueSeakBarView_x8_value_seekbar_float, false);
    a.recycle();
    if (this.isFloat) {
        this.MAX = (int) (this.seekBarMax - this.seekBarMin);
    } else {
        this.MAX = (int) (this.seekBarMax - this.seekBarMin);
    }
}
 
源代码6 项目: MNCalendar   文件: MNCalendar.java
public MNCalendar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.context = context;

    //自定义属性获取
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.MNCalendar);
    maxYear = ta.getInteger(R.styleable.MNCalendar_mnCalendar_maxYear, 2100);
    minYear = ta.getInteger(R.styleable.MNCalendar_mnCalendar_minYear, 1900);
    ta.recycle();

    Log.e(TAG, "maxYear : " + maxYear + " , minYear : " + minYear);

    //初始化相关
    init();
}
 
源代码7 项目: UltimateAndroid   文件: BlurDrawerLayout.java
public BlurDrawerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.BlurDrawerLayout, 0, 0);
    try {

        int drawerUpImage = ta.getResourceId(R.styleable.BlurDrawerLayout_drawerUpImageId, 0);
        int openDescription = ta.getResourceId(R.styleable.BlurDrawerLayout_openDescription, 0);
        int closeDescription = ta.getResourceId(R.styleable.BlurDrawerLayout_closeDescription, 0);

        int blurRadius = ta.getInteger(R.styleable.BlurDrawerLayout_blurRadius,
                BlurActionBarDrawerToggle.DEFAULT_BLUR_RADIUS);

        float downScaleFactor = ta.getFloat(R.styleable.BlurDrawerLayout_downScaleFactor,
                BlurActionBarDrawerToggle.DEFAULT_DOWNSCALEFACTOR);

        blurActionBarDrawerToggle = new BlurActionBarDrawerToggle(
                (Activity) context,
                this,
                drawerUpImage,
                openDescription,
                closeDescription);

        blurActionBarDrawerToggle.setRadius(blurRadius);
        blurActionBarDrawerToggle.setDownScaleFactor(downScaleFactor);

        setDrawerListener(blurActionBarDrawerToggle);

        post(new Runnable() {
            @Override
            public void run() {
                blurActionBarDrawerToggle.syncState();
            }
        });

    } finally {
        ta.recycle();
    }
}
 
@Override
public void loadFromAttributes(@Nullable AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, 
            R.styleable.DynamicTextInputEditText);

    try {
        mColorType = a.getInt(
                R.styleable.DynamicTextInputEditText_ads_colorType,
                Theme.ColorType.ACCENT);
        mContrastWithColorType = a.getInt(
                R.styleable.DynamicTextInputEditText_ads_contrastWithColorType,
                Theme.ColorType.BACKGROUND);
        mColor = a.getColor(
                R.styleable.DynamicTextInputEditText_ads_color,
                WidgetDefaults.ADS_COLOR_UNKNOWN);
        mContrastWithColor = a.getColor(
                R.styleable.DynamicTextInputEditText_ads_contrastWithColor,
                WidgetDefaults.getContrastWithColor(getContext()));
        mBackgroundAware = a.getInteger(
                R.styleable.DynamicTextInputEditText_ads_backgroundAware,
                WidgetDefaults.getBackgroundAware());

        if (mColorType == Theme.ColorType.ACCENT) {
            setTextColor(DynamicColorUtils.getContrastColor(
                    DynamicTheme.getInstance().get().getTextPrimaryColor(),
                    DynamicTheme.getInstance().get().getBackgroundColor()));
            setHintTextColor(DynamicColorUtils.getContrastColor(
                    DynamicTheme.getInstance().get().getTextSecondaryColor(),
                    DynamicTheme.getInstance().get().getBackgroundColor()));
        }
    } finally {
        a.recycle();
    }

    initialize();
}
 
源代码9 项目: ExpandableLayout   文件: ExpandableLinearLayout.java
private void init(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.expandableLayout, defStyleAttr, 0);
    duration = a.getInteger(R.styleable.expandableLayout_ael_duration, DEFAULT_DURATION);
    defaultExpanded = a.getBoolean(R.styleable.expandableLayout_ael_expanded, DEFAULT_EXPANDED);
    defaultChildIndex = a.getInteger(R.styleable.expandableLayout_ael_defaultChildIndex,
            Integer.MAX_VALUE);
    defaultPosition = a.getDimensionPixelSize(R.styleable.expandableLayout_ael_defaultPosition,
            Integer.MIN_VALUE);
    final int interpolatorType = a.getInteger(R.styleable.expandableLayout_ael_interpolator,
            Utils.LINEAR_INTERPOLATOR);
    a.recycle();
    interpolator = Utils.createInterpolator(interpolatorType);
    isExpanded = defaultExpanded;
}
 
源代码10 项目: libcommon   文件: SubTitleListPreferenceV7.java
public SubTitleListPreferenceV7(final Context context, final AttributeSet attrs, final int defStyle) {
	super(context, attrs, defStyle);
	TypedArray attribs = context.getTheme().obtainStyledAttributes(
		attrs, R.styleable.SubTitlePreference, defStyle, 0);
	mSubTitleLayoutId = attribs.getResourceId(R.styleable.SubTitlePreference_subtitle_layout, R.layout.subtitle);
	mSubTitleTvId = attribs.getResourceId(R.styleable.SubTitlePreference_subtitle_id, R.id.subtitle);
	mSubTitle = attribs.getString(R.styleable.SubTitlePreference_subtitle);
	mSubTitleVisibility = attribs.getInteger(R.styleable.SubTitlePreference_subtitle_visibility, View.VISIBLE);
	attribs.recycle();
}
 
源代码11 项目: ShapeView   文件: ShapeView.java
private void init(Context context, AttributeSet attrs) {
    if (attrs != null) {
        final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ShapeView);
        shapeType = typedArray.getInteger(R.styleable.ShapeView_shape_type, shapeType);

        if (shapeType == TRIANGLE) {
            percentLeft = typedArray.getFloat(R.styleable.ShapeView_shape_triangle_percentLeft, percentLeft);
            percentBottom = typedArray.getFloat(R.styleable.ShapeView_shape_triangle_percentBottom, percentBottom);
            percentRight = typedArray.getFloat(R.styleable.ShapeView_shape_triangle_percentRight, percentRight);
        }

        if (shapeType == HEART) {
            heartRadian = typedArray.getFloat(R.styleable.ShapeView_shape_heart_radian, heartRadian);
            heartYPercent = typedArray.getFloat(R.styleable.ShapeView_shape_heart_YPercent, heartYPercent);
        }

        if (shapeType == POLYGON) {
            sides = typedArray.getInteger(R.styleable.ShapeView_shape_polygon_side, sides);
            turn = typedArray.getFloat(R.styleable.ShapeView_shape_polygon_turn, turn);
        }

        if (shapeType == DIAGONAL) {
            diagonalAngle = typedArray.getInteger(R.styleable.ShapeView_shape_diagonal_angle, diagonalAngle);
            diagonalDirection = typedArray.getInteger(R.styleable.ShapeView_shape_diagonal_direction, diagonalDirection);
            diagonalPosition = typedArray.getInteger(R.styleable.ShapeView_shape_diagonal_position, diagonalPosition);
        }

        typedArray.recycle();
    }

    super.setClipHelper(new ClipHelper() {
        @Override
        public Path createClipPath(int width, int height) {
            final Path path = new Path();
            clipPath =  IClipPathFactory.create(shapeType,ShapeView.this);
            clipPath.setClipPath(path,width,height);
            return path;
        }
    });
}
 
源代码12 项目: RxZhihuDaily   文件: ViewPagerCompact.java
public LayoutParams(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    gravity = a.getInteger(0, Gravity.TOP);
    a.recycle();
}
 
源代码13 项目: arcusandroid   文件: ScleraTextView.java
private void init(@NonNull Context ctx, AttributeSet attrs) {
    TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.ScleraTextView);
    int customFont = a.getInteger(R.styleable.ScleraTextView_scleraFontStyle, -1);
    int htmlResId = a.getResourceId(R.styleable.ScleraTextView_html, 0);
    String htmlString = a.getString(R.styleable.ScleraTextView_html);

    setFont(customFont);
    setHtmlContent(htmlResId, htmlString);

    a.recycle();
}
 
源代码14 项目: screenstandby   文件: FlowLayout.java
private void readStyleParameters(Context context, AttributeSet attributeSet) {
    TypedArray a = context.obtainStyledAttributes(attributeSet, R.styleable.FlowLayout);
    try {
        horizontalSpacing = a.getDimensionPixelSize(R.styleable.FlowLayout_horizontalSpacing, 0);
        verticalSpacing = a.getDimensionPixelSize(R.styleable.FlowLayout_verticalSpacing, 0);
        orientation = a.getInteger(R.styleable.FlowLayout_orientation, HORIZONTAL);
        debugDraw = a.getBoolean(R.styleable.FlowLayout_debugDraw, false);
    } finally {
        a.recycle();
    }
}
 
源代码15 项目: FlexibleCalendar   文件: FlexibleCalendarView.java
private void setAttributes(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.FlexibleCalendarView);
    try {
        Calendar cal = Calendar.getInstance(FlexibleCalendarHelper.getLocale(context));
        displayMonth = a.getInteger(R.styleable.FlexibleCalendarView_startDisplayMonth, cal.get(Calendar.MONTH));
        displayYear = a.getInteger(R.styleable.FlexibleCalendarView_startDisplayYear, cal.get(Calendar.YEAR));
        startDisplayDay = cal.get(Calendar.DAY_OF_MONTH);

        weekdayHorizontalSpacing = (int) a.getDimension(R.styleable.FlexibleCalendarView_weekDayHorizontalSpacing, 0);
        weekdayVerticalSpacing = (int) a.getDimension(R.styleable.FlexibleCalendarView_weekDayVerticalSpacing, 0);
        monthDayHorizontalSpacing = (int) a.getDimension(R.styleable.FlexibleCalendarView_monthDayHorizontalSpacing, 0);
        monthDayVerticalSpacing = (int) a.getDimension(R.styleable.FlexibleCalendarView_monthDayVerticalSpacing, 0);

        monthViewBackground = a.getResourceId(R.styleable.FlexibleCalendarView_monthViewBackground, android.R.color.transparent);
        weekViewBackground = a.getResourceId(R.styleable.FlexibleCalendarView_weekViewBackground, android.R.color.transparent);

        showDatesOutsideMonth = a.getBoolean(R.styleable.FlexibleCalendarView_showDatesOutsideMonth, false);
        decorateDatesOutsideMonth = a.getBoolean(R.styleable.FlexibleCalendarView_decorateDatesOutsideMonth, false);
        disableAutoDateSelection = a.getBoolean(R.styleable.FlexibleCalendarView_disableAutoDateSelection, false);

        startDayOfTheWeek = a.getInt(R.styleable.FlexibleCalendarView_startDayOfTheWeek, Calendar.SUNDAY);
        if (startDayOfTheWeek < 1 || startDayOfTheWeek > 7) {
            // setting the start day to sunday in case of invalid input
            startDayOfTheWeek = Calendar.SUNDAY;
        }

    } finally {
        a.recycle();
    }
}
 
源代码16 项目: Common   文件: RowLayout.java
public RowLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.lib_pub_RowLayout);
    mLayout = typedArray.getResourceId(R.styleable.lib_pub_RowLayout_lib_pub_rl_layout, R.layout.lib_pub_layout_row);
    mContent = typedArray.getString(R.styleable.lib_pub_RowLayout_lib_pub_rl_text);
    mHint = typedArray.getString(R.styleable.lib_pub_RowLayout_lib_pub_rl_hint);
    mIcon = typedArray.getDrawable(R.styleable.lib_pub_RowLayout_lib_pub_rl_icon);
    mVisibilityToggle = typedArray.getInteger(R.styleable.lib_pub_RowLayout_lib_pub_rl_toggleVisibility, 0);
    mVisibilityGoto = typedArray.getInteger(R.styleable.lib_pub_RowLayout_lib_pub_rl_gotoVisibility, 0);
    typedArray.recycle();
    init(context);
}
 
源代码17 项目: AndroidImageSlider   文件: ViewPagerEx.java
public LayoutParams(Context context, AttributeSet attrs) {
    super(context, attrs);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    gravity = a.getInteger(0, Gravity.TOP);
    a.recycle();
}
 
源代码18 项目: FastAccess   文件: ColorPreference.java
@Override protected Object onGetDefaultValue(TypedArray a, int index) {
    return a.getInteger(index, DEFAULT_VALUE);
}
 
源代码19 项目: Smartlab   文件: PersianDatePicker.java
public PersianDatePicker(final Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	View root = inflater.inflate(R.layout.pdp, this);
	yearNumberPicker = (NumberPicker) root
			.findViewById(R.id.yearNumberPicker);
	monthNumberPicker = (NumberPicker) root
			.findViewById(R.id.monthNumberPicker);
	dayNumberPicker = (NumberPicker) root
			.findViewById(R.id.dayNumberPicker);

	TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PersianDatePicker, 0, 0);
	int year = 1393,month=6,day=19;
	
	year = a.getInteger(R.styleable.PersianDatePicker_year, 1393);
	month = a.getInteger(R.styleable.PersianDatePicker_month, 6);
	day = a.getInteger(R.styleable.PersianDatePicker_day, 19);
	
	a.recycle();

	yearNumberPicker.setMinValue(1380);
	yearNumberPicker.setMaxValue(1400);
	yearNumberPicker.setValue(year);

	monthNumberPicker.setMinValue(1);
	monthNumberPicker.setMaxValue(12);
	monthNumberPicker.setValue(month);

	dayNumberPicker.setMaxValue(31);
	dayNumberPicker.setMinValue(1);
	dayNumberPicker.setValue(day);
	
	yearNumberPicker.setOnValueChangedListener(new OnValueChangeListener() {
		
		@Override
		public void onValueChange(NumberPicker np, int oldValue, int newValue) {
			Toast.makeText(context, "Year changed:" + oldValue + " -> " + newValue, Toast.LENGTH_LONG).show();
		}
	});
}
 
源代码20 项目: ColorPicker   文件: ColorPreference.java
@Override protected Object onGetDefaultValue(TypedArray a, int index) {
  return a.getInteger(index, Color.BLACK);
}