Java Code Examples for android.content.res.TypedArray.getBoolean()

The following are Jave code examples for showing how to use getBoolean() of the android.content.res.TypedArray class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AppFirCloud   File: BaseRecyclerView.java   View Source Code Vote up 6 votes
private void initStyleable(Context context, AttributeSet attrs) {
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BaseRecyclerView);
    layoutMode = array.getInt(R.styleable.BaseRecyclerView_layoutMode, VERTICAL);
    spanCount = array.getInt(R.styleable.BaseRecyclerView_columnCount, 3);
    rowDivider = array.getBoolean(R.styleable.BaseRecyclerView_row_divider, false);
    spanDivider = array.getBoolean(R.styleable.BaseRecyclerView_span_divider, false);

    dividerWidth = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_width, 1f);
    dividerHeight = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_height, 1f);
    marginLeft = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginLeft, 0f);
    marginRight = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginRight, 0f);
    marginTop = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginTop, 0f);
    marginBottom = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginBottom, 0f);
    dividerColor = array.getColor(R.styleable.BaseRecyclerView_divider_color, Color.TRANSPARENT);
    array.recycle();
}
 
Example 2
Project: cleanarchitecture-unidirectional   File: LoadingRetryView.java   View Source Code Vote up 6 votes
public LoadingRetryView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray a = context.getTheme().obtainStyledAttributes(
            attrs,
            R.styleable.LoadingRetryView,
            defStyleAttr, 0);

    try {
        if (a.hasValue(R.styleable.LoadingRetryView_loadingMessage)) {
            loadingMessage = a.getString(R.styleable.LoadingRetryView_loadingMessage);
        } else {
            loadingMessage = context.getString(R.string.default_loading_message);
        }
        if (a.hasValue(R.styleable.LoadingRetryView_retryMessage)) {
            retryMessage = a.getString(R.styleable.LoadingRetryView_retryMessage);
        } else {
            retryMessage = context.getString(R.string.default_loading_message);
        }
        showLoadingMessage = a.getBoolean(R.styleable.LoadingRetryView_showLoadingMessage, true);
        showRetryMessage = a.getBoolean(R.styleable.LoadingRetryView_showRetryMessage, true);
        state = a.getInteger(R.styleable.LoadingRetryView_state, 0);
    } finally {
        a.recycle();
    }
}
 
Example 3
Project: ViewPagerHelper   File: TabIndicator.java   View Source Code Vote up 6 votes
public TabIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.TabIndicator);
    mCount = ta.getInt(R.styleable.TabIndicator_visiabel_size,4);
    mTabWidth = ta.getDimensionPixelSize(R.styleable.TabIndicator_tab_width,30);
    mTabHeight = ta.getDimensionPixelSize(R.styleable.TabIndicator_tab_height,10);
    mTriColor = ta.getResourceId(R.styleable.TabIndicator_tab_color,R.color.page_white);
    mDefaultColor = ta.getColor(R.styleable.TabIndicator_tab_text_default_color,mDefaultColor);
    mChangeColor = ta.getColor(R.styleable.TabIndicator_tab_text_change_color,mChangeColor);
    mTextSize = ta.getDimensionPixelSize(R.styleable.TabIndicator_tab_textsize,
            getResources().getDimensionPixelSize(R.dimen.tabsize));
    mTabtyle = ta.getInteger(R.styleable.TabIndicator_tap_type,1);

    mTextType = ta.getInteger(R.styleable.TabIndicator_tab_text_type,1);
    isShowTab = ta.getBoolean(R.styleable.TabIndicator_tab_show,isShowTab);
    ta.recycle();
    initData();

}
 
Example 4
Project: androidgithub   File: BaseRecyclerView.java   View Source Code Vote up 6 votes
private void initStyleable(Context context, AttributeSet attrs) {
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BaseRecyclerView);
    layoutMode = array.getInt(R.styleable.BaseRecyclerView_layoutMode, VERTICAL);
    spanCount = array.getInt(R.styleable.BaseRecyclerView_columnCount, 3);
    rowDivider = array.getBoolean(R.styleable.BaseRecyclerView_row_divider, false);
    spanDivider = array.getBoolean(R.styleable.BaseRecyclerView_span_divider, false);

    dividerWidth = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_width, 1f);
    dividerHeight = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_height, 1f);
    marginLeft = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginLeft, 0f);
    marginRight = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginRight, 0f);
    marginTop = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginTop, 0f);
    marginBottom = (int) array.getDimension(R.styleable.BaseRecyclerView_divider_marginBottom, 0f);
    dividerColor = array.getColor(R.styleable.BaseRecyclerView_divider_color, Color.TRANSPARENT);
    array.recycle();
}
 
Example 5
Project: VirtualHook   File: LauncherIconView.java   View Source Code Vote up 6 votes
private void init(Context context, AttributeSet attrs) {
    mMediumAnimTime = getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressImageView);
    try {
        this.mProgress = a.getInteger(R.styleable.ProgressImageView_pi_progress, 0);
        this.mStrokeWidth = a.getDimensionPixelOffset(R.styleable.ProgressImageView_pi_stroke, 8);
        this.mRadius = a.getDimensionPixelOffset(R.styleable.ProgressImageView_pi_radius, 0);
        this.mIsSquare = a.getBoolean(R.styleable.ProgressImageView_pi_force_square, false);
        this.mMaskColor = a.getColor(R.styleable.ProgressImageView_pi_mask_color, Color.argb(180, 0, 0, 0));

        this.mPaint = new Paint();
        mPaint.setColor(mMaskColor);
        mPaint.setAntiAlias(true);

        this.mShimmerPaint = new Paint();
        mShimmerPaint.setColor(Color.WHITE);
    } finally {
        a.recycle();
    }
    mShimmerViewHelper = new ShimmerViewHelper(this, mShimmerPaint, attrs);
}
 
Example 6
Project: Bigbang   File: ColorPickerPreference.java   View Source Code Vote up 5 votes
private void initWith(Context context, AttributeSet attrs) {
	final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ColorPickerPreference);

	try {
		alphaSlider = typedArray.getBoolean(R.styleable.ColorPickerPreference_alphaSlider, false);
		lightSlider = typedArray.getBoolean(R.styleable.ColorPickerPreference_lightnessSlider, false);

		density = typedArray.getInt(R.styleable.ColorPickerPreference_density, 10);
		wheelType = ColorPickerView.WHEEL_TYPE.indexOf(typedArray.getInt(R.styleable.ColorPickerPreference_wheelType, 0));

		selectedColor = typedArray.getInt(R.styleable.ColorPickerPreference_initialColor, 0xffffffff);

		pickerTitle = typedArray.getString(R.styleable.ColorPickerPreference_pickerTitle);
		if (pickerTitle==null)
			pickerTitle = "Choose color";

		pickerButtonCancel = typedArray.getString(R.styleable.ColorPickerPreference_pickerButtonCancel);
		if (pickerButtonCancel==null)
			pickerButtonCancel = "cancel";

		pickerButtonOk = typedArray.getString(R.styleable.ColorPickerPreference_pickerButtonOk);
		if (pickerButtonOk==null)
			pickerButtonOk = "ok";

	} finally {
		typedArray.recycle();
	}

	setWidgetLayoutResource(R.layout.color_widget);
}
 
Example 7
Project: stynico   File: AutofitHelper.java   View Source Code Vote up 5 votes
/**
    * Creates a new instance of {@code AutofitHelper} that wraps a {@link TextView} and enables
    * automatically sizing the text to fit.
    */
   public static AutofitHelper create(AppCompatTextView view, AttributeSet attrs, int defStyle)
{
       AutofitHelper helper = new AutofitHelper(view);
       boolean sizeToFit = true;
       if (attrs != null)
	{
           Context context = view.getContext();
           int minTextSize = (int) helper.getMinTextSize();
           float precision = helper.getPrecision();

           TypedArray ta = context.obtainStyledAttributes(
			attrs,
			R.styleable.AutofitTextView,
			defStyle,
			0);
           sizeToFit = ta.getBoolean(R.styleable.AutofitTextView_sizeToFit, sizeToFit);
           minTextSize = ta.getDimensionPixelSize(R.styleable.AutofitTextView_minTextSize,
											   minTextSize);
           precision = ta.getFloat(R.styleable.AutofitTextView_precision, precision);
           ta.recycle();

           helper.setMinTextSize(TypedValue.COMPLEX_UNIT_PX, minTextSize)
               .setPrecision(precision);
       }
       helper.setEnabled(sizeToFit);

       return helper;
   }
 
Example 8
Project: FlickLauncher   File: InsettableFrameLayout.java   View Source Code Vote up 5 votes
public LayoutParams(Context c, AttributeSet attrs) {
    super(c, attrs);
    TypedArray a = c.obtainStyledAttributes(attrs,
            R.styleable.InsettableFrameLayout_Layout);
    ignoreInsets = a.getBoolean(
            R.styleable.InsettableFrameLayout_Layout_layout_ignoreInsets, false);
    a.recycle();
}
 
Example 9
Project: RLibrary   File: SlidingTabLayout.java   View Source Code Vote up 5 votes
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);

    mIndicatorStyle = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_style, STYLE_NORMAL);
    mIndicatorColor = ta.getColor(R.styleable.SlidingTabLayout_tl_indicator_color, Color.parseColor(mIndicatorStyle == STYLE_BLOCK ? "#4B6A87" : "#ffffff"));
    mIndicatorHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_height,
            dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 4 : (mIndicatorStyle == STYLE_BLOCK ? -1 : 2)));
    mIndicatorWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_width, dp2px(mIndicatorStyle == STYLE_TRIANGLE ? 10 : -1));
    mIndicatorCornerRadius = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_corner_radius, dp2px(mIndicatorStyle == STYLE_BLOCK ? -1 : 0));
    mIndicatorMarginLeft = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_left, dp2px(0));
    mIndicatorMarginTop = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_top, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorMarginRight = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_right, dp2px(0));
    mIndicatorMarginBottom = ta.getDimension(R.styleable.SlidingTabLayout_tl_indicator_margin_bottom, dp2px(mIndicatorStyle == STYLE_BLOCK ? 7 : 0));
    mIndicatorGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_indicator_gravity, Gravity.BOTTOM);
    mIndicatorWidthEqualTitle = ta.getBoolean(R.styleable.SlidingTabLayout_tl_indicator_width_equal_title, false);

    mUnderlineColor = ta.getColor(R.styleable.SlidingTabLayout_tl_underline_color, Color.parseColor("#ffffff"));
    mUnderlineHeight = ta.getDimension(R.styleable.SlidingTabLayout_tl_underline_height, dp2px(0));
    mUnderlineGravity = ta.getInt(R.styleable.SlidingTabLayout_tl_underline_gravity, Gravity.BOTTOM);

    mDividerColor = ta.getColor(R.styleable.SlidingTabLayout_tl_divider_color, Color.parseColor("#ffffff"));
    mDividerWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_width, dp2px(0));
    mDividerPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_divider_padding, dp2px(12));

    mTextsize = ta.getDimension(R.styleable.SlidingTabLayout_tl_textsize, sp2px(14));
    mTextSelectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
    mTextUnselectColor = ta.getColor(R.styleable.SlidingTabLayout_tl_textUnselectColor, Color.parseColor("#AAffffff"));
    mTextBold = ta.getInt(R.styleable.SlidingTabLayout_tl_textBold, TEXT_BOLD_NONE);
    mTextAllCaps = ta.getBoolean(R.styleable.SlidingTabLayout_tl_textAllCaps, false);

    mTabSpaceEqual = ta.getBoolean(R.styleable.SlidingTabLayout_tl_tab_space_equal, false);
    mTabWidth = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_width, dp2px(-1));
    mTabPadding = ta.getDimension(R.styleable.SlidingTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(20));

    ta.recycle();
}
 
Example 10
Project: VirtualHook   File: CardStackLayout.java   View Source Code Vote up 5 votes
private void handleArgs(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	resetDefaults();

	final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CardStackLayout, defStyleAttr,
			defStyleRes);
	mParallaxEnabled = a.getBoolean(R.styleable.CardStackLayout_parallax_enabled, PARALLAX_ENABLED_DEFAULT);
	mShowInitAnimation = a.getBoolean(R.styleable.CardStackLayout_showInitAnimation, SHOW_INIT_ANIMATION_DEFAULT);
	mParallaxScale = a.getInteger(R.styleable.CardStackLayout_parallax_scale,
			getResources().getInteger(R.integer.parallax_scale_default));
	mCardGap = a.getDimension(R.styleable.CardStackLayout_card_gap, getResources().getDimension(R.dimen.card_gap));
	mCardGapBottom = a.getDimension(R.styleable.CardStackLayout_card_gap_bottom,
			getResources().getDimension(R.dimen.card_gap_bottom));

	a.recycle();
}
 
Example 11
Project: Mobike   File: TabTitleView.java   View Source Code Vote up 5 votes
public TabTitleView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mInflater = LayoutInflater.from(context);
    initView();

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabTitleView, defStyleAttr, defStyleRes);
        left_ImagViewDrawble = a.getDrawable(R.styleable.TabTitleView_leftImageIcon);
        if (left_ImagViewDrawble == null) {
            left_ImagViewDrawble = getResources().getDrawable(R.drawable.up_arrow, null);
        } else {
            setleft_ImagViewDrawable(left_ImagViewDrawble);
        }
        showRightTextView = a.getBoolean(R.styleable.TabTitleView_showRightTextView, false);
        if (showRightTextView) {
            setRigtTvVisiable(View.VISIBLE);
        } else {
            setRigtTvVisiable(View.GONE);
        }

        int rightTvcolor = a.getColor(R.styleable.TabTitleView_rightTvColor, getResources()
                .getColor(R.color.white));
        setRigtTvColor(rightTvcolor);

        String title = a.getString(R.styleable.TabTitleView_titleText);
        String rightTvText = a.getString(R.styleable.TabTitleView_rightText);

        setTitleText(title);

        setRigtTvText(rightTvText);

        a.recycle();

    }
    initListener();

}
 
Example 12
Project: GitHub   File: SegmentTabLayout.java   View Source Code Vote up 5 votes
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SegmentTabLayout);

    mIndicatorColor = ta.getColor(R.styleable.SegmentTabLayout_tl_indicator_color, Color.parseColor("#222831"));
    mIndicatorHeight = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_height, -1);
    mIndicatorCornerRadius = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_corner_radius, -1);
    mIndicatorMarginLeft = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_left, dp2px(0));
    mIndicatorMarginTop = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_top, 0);
    mIndicatorMarginRight = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_right, dp2px(0));
    mIndicatorMarginBottom = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_bottom, 0);
    mIndicatorAnimEnable = ta.getBoolean(R.styleable.SegmentTabLayout_tl_indicator_anim_enable, false);
    mIndicatorBounceEnable = ta.getBoolean(R.styleable.SegmentTabLayout_tl_indicator_bounce_enable, true);
    mIndicatorAnimDuration = ta.getInt(R.styleable.SegmentTabLayout_tl_indicator_anim_duration, -1);

    mDividerColor = ta.getColor(R.styleable.SegmentTabLayout_tl_divider_color, mIndicatorColor);
    mDividerWidth = ta.getDimension(R.styleable.SegmentTabLayout_tl_divider_width, dp2px(1));
    mDividerPadding = ta.getDimension(R.styleable.SegmentTabLayout_tl_divider_padding, 0);

    mTextsize = ta.getDimension(R.styleable.SegmentTabLayout_tl_textsize, sp2px(13f));
    mTextSelectColor = ta.getColor(R.styleable.SegmentTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
    mTextUnselectColor = ta.getColor(R.styleable.SegmentTabLayout_tl_textUnselectColor, mIndicatorColor);
    mTextBold = ta.getInt(R.styleable.SegmentTabLayout_tl_textBold, TEXT_BOLD_NONE);
    mTextAllCaps = ta.getBoolean(R.styleable.SegmentTabLayout_tl_textAllCaps, false);

    mTabSpaceEqual = ta.getBoolean(R.styleable.SegmentTabLayout_tl_tab_space_equal, true);
    mTabWidth = ta.getDimension(R.styleable.SegmentTabLayout_tl_tab_width, dp2px(-1));
    mTabPadding = ta.getDimension(R.styleable.SegmentTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(10));

    mBarColor = ta.getColor(R.styleable.SegmentTabLayout_tl_bar_color, Color.TRANSPARENT);
    mBarStrokeColor = ta.getColor(R.styleable.SegmentTabLayout_tl_bar_stroke_color, mIndicatorColor);
    mBarStrokeWidth = ta.getDimension(R.styleable.SegmentTabLayout_tl_bar_stroke_width, dp2px(1));

    ta.recycle();
}
 
Example 13
Project: AutoResizeEditText   File: AutofitHelper.java   View Source Code Vote up 5 votes
/**
 * Creates a new instance of {@code AutofitHelper} that wraps a {@link TextView} and enables
 * automatically sizing the text to fit.
 */
public static AutofitHelper create(TextView view, AttributeSet attrs, int defStyle) {
    AutofitHelper helper = new AutofitHelper(view);
    boolean sizeToFit = true;
    if (attrs != null) {
        Context context = view.getContext();
        int minTextSize = (int) helper.getMinTextSize();
        float precision = helper.getPrecision();

        TypedArray ta = context.obtainStyledAttributes(
                attrs,
                R.styleable.AutofitEditText,
                defStyle,
                0);
        sizeToFit = ta.getBoolean(R.styleable.AutofitEditText_sizeToFit, sizeToFit);
        minTextSize = ta.getDimensionPixelSize(R.styleable.AutofitEditText_minTextSize,
                minTextSize);
        precision = ta.getFloat(R.styleable.AutofitEditText_precision, precision);
        ta.recycle();

        helper.setMinTextSize(TypedValue.COMPLEX_UNIT_PX, minTextSize)
                .setPrecision(precision);
    }
    helper.setEnabled(sizeToFit);

    return helper;
}
 
Example 14
Project: floating_calc   File: SolidPadLayout.java   View Source Code Vote up 5 votes
public SolidPadLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    if (attrs != null) {
        final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SolidLayout, 0, 0);
        mPreventParentTouchEvents = a.getBoolean(R.styleable.SolidLayout_preventParentTouchEvents, mPreventParentTouchEvents);
        mPreventChildTouchEvents = a.getBoolean(R.styleable.SolidLayout_preventChildTouchEvents, mPreventChildTouchEvents);
        a.recycle();
    }
}
 
Example 15
Project: androidgithub   File: SwipeMenuLayout.java   View Source Code Vote up 5 votes
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    mScaleTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mMaxVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
    //初始化滑动帮助类对象
    //mScroller = new Scroller(context);

    //右滑删除功能的开关,默认开
    isSwipeEnable = true;
    //IOS、QQ式交互,默认开
    isIos = true;
    //左滑右滑的开关,默认左滑打开菜单
    isLeftSwipe = true;
    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.SwipeMenuLayout, defStyleAttr, 0);
    int count = ta.getIndexCount();
    for (int i = 0; i < count; i++) {
        int attr = ta.getIndex(i);
        //如果引用成AndroidLib 资源都不是常量,无法使用switch case
        if (attr == R.styleable.SwipeMenuLayout_swipeEnable) {
            isSwipeEnable = ta.getBoolean(attr, true);
        } else if (attr == R.styleable.SwipeMenuLayout_ios) {
            isIos = ta.getBoolean(attr, true);
        } else if (attr == R.styleable.SwipeMenuLayout_leftSwipe) {
            isLeftSwipe = ta.getBoolean(attr, true);
        }
    }
    ta.recycle();


}
 
Example 16
Project: aarLibrary   File: SegmentTabLayout.java   View Source Code Vote up 5 votes
private void obtainAttributes(Context context, AttributeSet attrs) {
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SegmentTabLayout);

    mIndicatorColor = ta.getColor(R.styleable.SegmentTabLayout_tl_indicator_color, Color.parseColor("#222831"));
    mIndicatorHeight = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_height, -1);
    mIndicatorCornerRadius = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_corner_radius, -1);
    mIndicatorMarginLeft = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_left, dp2px(0));
    mIndicatorMarginTop = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_top, 0);
    mIndicatorMarginRight = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_right, dp2px(0));
    mIndicatorMarginBottom = ta.getDimension(R.styleable.SegmentTabLayout_tl_indicator_margin_bottom, 0);
    mIndicatorAnimEnable = ta.getBoolean(R.styleable.SegmentTabLayout_tl_indicator_anim_enable, false);
    mIndicatorBounceEnable = ta.getBoolean(R.styleable.SegmentTabLayout_tl_indicator_bounce_enable, true);
    mIndicatorAnimDuration = ta.getInt(R.styleable.SegmentTabLayout_tl_indicator_anim_duration, -1);

    mDividerColor = ta.getColor(R.styleable.SegmentTabLayout_tl_divider_color, mIndicatorColor);
    mDividerWidth = ta.getDimension(R.styleable.SegmentTabLayout_tl_divider_width, dp2px(1));
    mDividerPadding = ta.getDimension(R.styleable.SegmentTabLayout_tl_divider_padding, 0);

    mTextsize = ta.getDimension(R.styleable.SegmentTabLayout_tl_textsize, sp2px(13f));
    mTextSelectColor = ta.getColor(R.styleable.SegmentTabLayout_tl_textSelectColor, Color.parseColor("#ffffff"));
    mTextUnselectColor = ta.getColor(R.styleable.SegmentTabLayout_tl_textUnselectColor, mIndicatorColor);
    mTextBold = ta.getInt(R.styleable.SegmentTabLayout_tl_textBold, TEXT_BOLD_NONE);
    mTextAllCaps = ta.getBoolean(R.styleable.SegmentTabLayout_tl_textAllCaps, false);

    mTabSpaceEqual = ta.getBoolean(R.styleable.SegmentTabLayout_tl_tab_space_equal, true);
    mTabWidth = ta.getDimension(R.styleable.SegmentTabLayout_tl_tab_width, dp2px(-1));
    mTabPadding = ta.getDimension(R.styleable.SegmentTabLayout_tl_tab_padding, mTabSpaceEqual || mTabWidth > 0 ? dp2px(0) : dp2px(10));

    mBarColor = ta.getColor(R.styleable.SegmentTabLayout_tl_bar_color, Color.TRANSPARENT);
    mBarStrokeColor = ta.getColor(R.styleable.SegmentTabLayout_tl_bar_stroke_color, mIndicatorColor);
    mBarStrokeWidth = ta.getDimension(R.styleable.SegmentTabLayout_tl_bar_stroke_width, dp2px(1));

    ta.recycle();
}
 
Example 17
Project: jackknife   File: HorizontalTabBar.java   View Source Code Vote up 4 votes
private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
    mIndicatorHeight = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, mMetrics);
    mUnderlineHeight = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, mMetrics);
    mDividerWidth = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, mMetrics);
    mDividerPaddingTop = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, mMetrics);
    mDividerPaddingBottom = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, mMetrics);
    mTabPaddingLeft = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, mMetrics);
    mTabPaddingRight = (int) TypedValue
            .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, mMetrics);
    mTabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, mMetrics);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HorizontalTabBar,
            defStyleAttr, 0);
    mIndicatorColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_indicatorColor,
            DEFAULT_INDICATOR_COLOR);
    mUnderlineColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_underlineColor,
            DEFAULT_UNDERLINE_COLOR);
    mDividerColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_dividerColor,
            DEFAULT_DIVIDER_COLOR);
    mIndicatorHeight = a.getDimensionPixelSize(
            R.styleable.HorizontalTabBar_horizontaltabbar_indicatorHeight, mIndicatorHeight);
    mUnderlineHeight = a.getDimensionPixelSize(
            R.styleable.HorizontalTabBar_horizontaltabbar_underlineHeight, mUnderlineHeight);
    mDividerPaddingTop = a.getDimensionPixelSize(
            R.styleable.HorizontalTabBar_horizontaltabbar_dividerPaddingTop,
            mDividerPaddingTop);
    mDividerPaddingBottom = a.
            getDimensionPixelSize(
                    R.styleable.HorizontalTabBar_horizontaltabbar_dividerPaddingBottom,
                    mDividerPaddingBottom);
    mTabPaddingLeft = a.getDimensionPixelSize(
            R.styleable.HorizontalTabBar_horizontaltabbar_tabPaddingLeft, mTabPaddingLeft);
    mTabPaddingRight = a.getDimensionPixelSize(
            R.styleable.HorizontalTabBar_horizontaltabbar_tabPaddingRight, mTabPaddingRight);
    mTabColor = a.getResourceId(R.styleable.HorizontalTabBar_horizontaltabbar_tabColor,
            DEFAULT_TAB_COLOR);
    mTabTextColor = a.getColor(R.styleable.HorizontalTabBar_horizontaltabbar_tabTextColor,
            DEFAULT_TAB_TEXT_COLOR);
    mSelectedTabTextColor = a.getColor(
            R.styleable.HorizontalTabBar_horizontaltabbar_tabSelectedTextColor,
            DEFAULT_SELECTED_TAB_TEXT_COLOR);
    mTabTextSize = a.getDimension(
            R.styleable.HorizontalTabBar_horizontaltabbar_tabTextSize, mTabTextSize);
    mAverage = a.getBoolean(R.styleable.HorizontalTabBar_horizontaltabbar_isAverage, mAverage);
    mTextAllCaps = a.getBoolean(R.styleable.HorizontalTabBar_horizontaltabbar_textAllCaps,
            mTextAllCaps);
    a.recycle();
}
 
Example 18
Project: letv   File: AbsHListView.java   View Source Code Vote up 4 votes
public AbsHListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mChoiceMode = 0;
    this.mLayoutMode = 0;
    this.mDrawSelectorOnTop = false;
    this.mSelectorPosition = -1;
    this.mSelectorRect = new Rect();
    this.mRecycler = new RecycleBin(this);
    this.mSelectionLeftPadding = 0;
    this.mSelectionTopPadding = 0;
    this.mSelectionRightPadding = 0;
    this.mSelectionBottomPadding = 0;
    this.mListPadding = new Rect();
    this.mHeightMeasureSpec = 0;
    this.mTouchMode = -1;
    this.mSelectedLeft = 0;
    this.mSmoothScrollbarEnabled = true;
    this.mResurrectToPosition = -1;
    this.mContextMenuInfo = null;
    this.mLastTouchMode = -1;
    this.mLastScrollState = 0;
    this.mVelocityScale = 1.0f;
    this.mIsScrap = new boolean[1];
    this.mActivePointerId = -1;
    this.mDirection = 0;
    initAbsListView();
    TypedArray array = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AbsHListView, defStyle, 0);
    Drawable listSelector = null;
    boolean drawSelectorOnTop = false;
    boolean stackFromRight = false;
    boolean scrollingCacheEnabled = true;
    int transcriptMode = 0;
    int color = 0;
    boolean smoothScrollbar = true;
    int choiceMode = 0;
    if (array != null) {
        listSelector = array.getDrawable(0);
        drawSelectorOnTop = array.getBoolean(1, false);
        stackFromRight = array.getBoolean(6, false);
        scrollingCacheEnabled = array.getBoolean(2, true);
        transcriptMode = array.getInt(7, 0);
        color = array.getColor(3, 0);
        smoothScrollbar = array.getBoolean(5, true);
        choiceMode = array.getInt(4, 0);
        array.recycle();
    }
    if (listSelector != null) {
        setSelector(listSelector);
    }
    this.mDrawSelectorOnTop = drawSelectorOnTop;
    setStackFromRight(stackFromRight);
    setScrollingCacheEnabled(scrollingCacheEnabled);
    setTranscriptMode(transcriptMode);
    setCacheColorHint(color);
    setSmoothScrollbarEnabled(smoothScrollbar);
    setChoiceMode(choiceMode);
}
 
Example 19
Project: boohee_v5.6   File: ButtonBarLayout.java   View Source Code Vote up 4 votes
public ButtonBarLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ButtonBarLayout);
    this.mAllowStacking = ta.getBoolean(R.styleable.ButtonBarLayout_allowStacking, false);
    ta.recycle();
}
 
Example 20
Project: android_ui   File: EditLayout.java   View Source Code Vote up 4 votes
/**
 * Called from one of constructors of this view to perform its initialization.
 * <p>
 * Initialization is done via parsing of the specified <var>attrs</var> set and obtaining for
 * this view specific data from it that can be used to configure this new view instance. The
 * specified <var>defStyleAttr</var> and <var>defStyleRes</var> are used to obtain default data
 * from the current theme provided by the specified <var>context</var>.
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
	/**
	 * Process attributes.
	 */
	this.mEditConfig = new EditConfig();
	boolean createViewHierarchy = true;
	final TypedArray attributes = mContext.obtainStyledAttributes(attrs, R.styleable.Ui_EditLayout, defStyleAttr, defStyleRes);
	for (int i = 0; i < attributes.getIndexCount(); i++) {
		final int index = attributes.getIndex(i);
		if (index == R.styleable.Ui_EditLayout_android_text) {
			mEditConfig.text = attributes.getText(index);
		} else if (index == R.styleable.Ui_EditLayout_android_hint) {
			mEditConfig.hint = attributes.getText(index);
		} else if (index == R.styleable.Ui_EditLayout_android_inputType) {
			mEditConfig.inputType = attributes.getInteger(index, mEditConfig.inputType);
		} else if (index == R.styleable.Ui_EditLayout_android_maxLength) {
			mLengthConstraint = mEditConfig.maxLength = attributes.getInteger(index, mEditConfig.maxLength);
		} else if (index == R.styleable.Ui_EditLayout_android_lines) {
			mEditConfig.lines = attributes.getInteger(index, mEditConfig.lines);
		} else if (index == R.styleable.Ui_EditLayout_android_minLines) {
			mEditConfig.minLines = attributes.getInteger(index, mEditConfig.minLines);
		} else if (index == R.styleable.Ui_EditLayout_android_maxLines) {
			mEditConfig.maxLines = attributes.getInteger(index, mEditConfig.maxLines);
		} else if (index == R.styleable.Ui_EditLayout_uiLengthConstraint) {
			this.mLengthConstraint = attributes.getInteger(index, mLengthConstraint);
		} else if (index == R.styleable.Ui_EditLayout_uiFloatingLabelAnimationIn) {
			final int inAnimRes = attributes.getResourceId(index, -1);
			if (inAnimRes != -1) {
				this.mLabelInAnimation = AnimationUtils.loadAnimation(mContext, inAnimRes);
			}
		} else if (index == R.styleable.Ui_EditLayout_uiFloatingLabelAnimationOut) {
			final int outAnimRes = attributes.getResourceId(index, -1);
			if (outAnimRes != -1) {
				this.mLabelOutAnimation = AnimationUtils.loadAnimation(mContext, outAnimRes);
				this.handleAnimationsUpdate();
			}
		} else if (index == R.styleable.Ui_EditLayout_uiWithEmptyViewHierarchy) {
			createViewHierarchy = !attributes.getBoolean(index, false);
		}
	}
	attributes.recycle();

	if (createViewHierarchy) {
		addLabelView(new TextViewWidget(context, null, R.attr.uiInputLabelStyle));
		addInputView(new EditTextWidget(context, null, R.attr.uiEditTextInputStyle));
		addNoteView(new TextViewWidget(context, null, R.attr.uiInputNoteStyle));
		addConstraintView(new TextViewWidget(context, null, R.attr.uiInputConstraintStyle));
		this.updateEditTextConfiguration();
	}
}