List of usage examples for android.content.res TypedArray getBoolean
public boolean getBoolean(@StyleableRes int index, boolean defValue)
From source file:banner.edgar.com.banner.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w .j a v a2 s . c om final Resources res = getResources(); //Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); }
From source file:cn.smilecity.viewpagerindicator.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w . j a v a2s .co m*/ final Resources res = getResources(); // Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.bg_title); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.apptentive.android.sdk.ApptentiveViewActivity.java
private int getToolbarHeightAdjustment(boolean bToolbarShown) { int adjustAmount = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { boolean translucentStatus = false; // check theme attrs to see if translucent statusbar is set explicitly int[] attrs = { android.R.attr.windowTranslucentStatus }; TypedArray a = getTheme().obtainStyledAttributes(attrs); try {//from w ww . j a v a 2 s .c o m translucentStatus = a.getBoolean(0, false); } finally { a.recycle(); } // also check window flags in case translucent statusbar is set implicitly WindowManager.LayoutParams winParams = getWindow().getAttributes(); int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if ((winParams.flags & bits) != 0) { translucentStatus = true; } if (translucentStatus) { if (bToolbarShown) { int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { adjustAmount = getResources().getDimensionPixelSize(resourceId); } } /* Add layout listener to ensure keyboard launch resize the screen when android:windowTranslucentStatus=true * Fixing workaround found here: * http://stackoverflow.com/questions/8398102/androidwindowsoftinputmode-adjustresize-doesnt-make-any-difference */ decorView = getWindow().getDecorView(); contentView = decorView.findViewById(android.R.id.content); decorView.getViewTreeObserver().addOnGlobalLayoutListener(keyboardPresencelLayoutListener); } } return adjustAmount; }
From source file:com.chrismorais.android.sunshine.app.ForecastFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0); mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE); mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false); a.recycle();//from w w w. j a v a 2 s .co m }
From source file:android.hqs.view.pager.indicator.UnderlinePageIndicator.java
/** * ?/* w ww . j av a2s.c o m*/ * @param context * @param attrs * @param defStyle */ @SuppressWarnings("deprecation") public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return; final Resources res = getResources(); //Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setBackground(background); } else { setBackgroundDrawable(background); } } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.example.abner.dynamicfragment.view.CustomSlidingTabLayout.java
public CustomSlidingTabLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // Disable the Scroll Bar setHorizontalScrollBarEnabled(false); // Make sure that the Tab Strips fills this View setFillViewport(true);/*from w w w . j a v a 2 s . co m*/ TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.CustomSlidingTabLayout, 0, 0); setShouldExpand(ta.getBoolean(R.styleable.CustomSlidingTabLayout_shouldExpand, false)); dTextColor = ta.getColor(R.styleable.CustomSlidingTabLayout_defaultTextColor, Color.BLACK); sTextColor = ta.getColor(R.styleable.CustomSlidingTabLayout_selectedTextColor, Color.RED); mTextSize = ta.getDimensionPixelOffset(R.styleable.CustomSlidingTabLayout_textSize, TAB_VIEW_TEXT_SIZE_SP); mNeedBold = ta.getBoolean(R.styleable.CustomSlidingTabLayout_needBold, false); mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density); mTabStrip = new CustomSlidingTabStrip(context); addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); // mTabStrip attrs int mBottomLineColor = ta.getColor(R.styleable.CustomSlidingTabLayout_BottomLineColor, getResources().getColor(R.color.grey_cccccc)); int mIndicatorHeight = ta.getDimensionPixelOffset(R.styleable.CustomSlidingTabLayout_IndicatorHeight, DensityUtils.dip2px(getContext(), 6)); int mBottomLineHeight = ta.getDimensionPixelOffset(R.styleable.CustomSlidingTabLayout_BottomLineHeight, 0); setBottomHeight(mBottomLineHeight); setIndicatorHeight(mIndicatorHeight); setBottomLineColor(mBottomLineColor); ta.recycle(); }
From source file:net.sf.sprockets.app.ui.SprocketsPreferenceFragment.java
@Override public void onInflate(Activity a, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(a, attrs, savedInstanceState); TypedArray array = a.obtainStyledAttributes(attrs, R.styleable.SprocketsPreferenceFragment); Bundle args = Fragments.arguments(this); args.putInt(PREFS, array.getResourceId(R.styleable.SprocketsPreferenceFragment_preferences, 0)); args.putBoolean(TRACK_CHANGES,/* w w w .j a v a 2 s .c o m*/ array.getBoolean(R.styleable.SprocketsPreferenceFragment_trackChanges, false)); array.recycle(); }
From source file:com.android.core.view.indicator.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w . ja v a2s .c om*/ final Resources res = getResources(); //Load defaults from resources final boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(R.color.default_underline_indicator_selected_color); final float defaultLineWidth = 0f; //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, defaultFades)); setSelectedColor(a.getColor(R.styleable.UnderlinePageIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.UnderlinePageIndicator_fadeLength, defaultFadeLength)); setLineWidth(a.getDimension(R.styleable.UnderlinePageIndicator_line_width, defaultLineWidth)); Drawable background = a.getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.appsummary.luoxf.myappsummary.recyclerView.fastscroll.Views.FastScroller.java
public FastScroller(Context context, FastScrollRecyclerView recyclerView, AttributeSet attrs) { Resources resources = context.getResources(); mRecyclerView = recyclerView;//from w w w . j ava 2s .c o m mPopup = new FastScrollPopup(resources, recyclerView); mThumbHeight = Utils.toPixels(resources, 48); mWidth = Utils.toPixels(resources, 8); mTouchInset = Utils.toPixels(resources, -24); mThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mTrack = new Paint(Paint.ANTI_ALIAS_FLAG); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FastScrollRecyclerView, 0, 0); try { mAutoHideEnabled = typedArray.getBoolean(R.styleable.FastScrollRecyclerView_fastScrollAutoHide, true); mAutoHideDelay = typedArray.getInteger(R.styleable.FastScrollRecyclerView_fastScrollAutoHideDelay, DEFAULT_AUTO_HIDE_DELAY); int trackColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollTrackColor, 0x1f000000); int thumbColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollThumbColor, 0xff000000); int popupBgColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupBgColor, 0xff000000); int popupTextColor = typedArray.getColor(R.styleable.FastScrollRecyclerView_fastScrollPopupTextColor, 0xffffffff); mTrack.setColor(trackColor); mThumb.setColor(thumbColor); mPopup.setBgColor(popupBgColor); mPopup.setTextColor(popupTextColor); } finally { typedArray.recycle(); } mHideRunnable = new Runnable() { @Override public void run() { if (!mIsDragging) { if (mAutoHideAnimator != null) { mAutoHideAnimator.cancel(); } mAutoHideAnimator = ObjectAnimator.ofInt(FastScroller.this, "offsetX", (Utils.isRtl(mRecyclerView.getResources()) ? -1 : 1) * mWidth); mAutoHideAnimator.setInterpolator(new FastOutLinearInInterpolator()); mAutoHideAnimator.setDuration(200); mAutoHideAnimator.start(); } } }; mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); show(); } }); if (mAutoHideEnabled) { postAutoHideDelayed(); } }
From source file:com.azhansy.linky.view.PagerSlidingIndicator.java
public PagerSlidingIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);//w ww. j a v a2s . c o m setWillNotDraw(false); DisplayMetrics dm = getResources().getDisplayMetrics(); scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm); backgroundStrokeWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, backgroundStrokeWidth, dm); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingIndicator); shouldExpand = a.getBoolean(R.styleable.PagerSlidingIndicator_shouldExpand, shouldExpand); scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingIndicator_scrollOffset, scrollOffset); backgroundStrokeColor = a.getColor(R.styleable.PagerSlidingIndicator_background_stroke_color, backgroundStrokeColor); backgroundStrokeWidth = a.getDimensionPixelSize(R.styleable.PagerSlidingIndicator_background_stroke_width, backgroundStrokeWidth); backgroundColor = a.getColor(R.styleable.PagerSlidingIndicator_background_color, backgroundColor); checkedBackgroundColor = a.getColor(R.styleable.PagerSlidingIndicator_checked_background_color, checkedBackgroundColor); a.recycle(); // backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); backgroundPaint.setColor(backgroundColor); backgroundPaint.setStyle(Style.FILL); // checkedBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG); checkedBackgroundPaint.setColor(checkedBackgroundColor); checkedBackgroundPaint.setStyle(Style.FILL); defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f); }