本文整理匯總了Java中android.content.res.Resources.getInteger方法的典型用法代碼示例。如果您正苦於以下問題:Java Resources.getInteger方法的具體用法?Java Resources.getInteger怎麽用?Java Resources.getInteger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.content.res.Resources
的用法示例。
在下文中一共展示了Resources.getInteger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import android.content.res.Resources; //導入方法依賴的package包/類
public static void init(final Resources res) {
// The proximate bogus down move up event hack is needed for a device such like,
// 1) is large tablet, or 2) is small tablet and the screen density is less than hdpi.
// Though it seems odd to use screen density as criteria of the quality of the touch
// screen, the small table that has a less density screen than hdpi most likely has been
// made with the touch screen that needs the hack.
final int screenMetrics = res.getInteger(R.integer.config_screen_metrics);
final boolean isLargeTablet = (screenMetrics == Constants.SCREEN_METRICS_LARGE_TABLET);
final boolean isSmallTablet = (screenMetrics == Constants.SCREEN_METRICS_SMALL_TABLET);
final int densityDpi = res.getDisplayMetrics().densityDpi;
final boolean hasLowDensityScreen = (densityDpi < DisplayMetrics.DENSITY_HIGH);
final boolean needsTheHack = isLargeTablet || (isSmallTablet && hasLowDensityScreen);
if (DEBUG_MODE) {
final int sw = res.getConfiguration().smallestScreenWidthDp;
Log.d(TAG, "needsProximateBogusDownMoveUpEventHack=" + needsTheHack
+ " smallestScreenWidthDp=" + sw + " densityDpi=" + densityDpi
+ " screenMetrics=" + screenMetrics);
}
sNeedsProximateBogusDownMoveUpEventHack = needsTheHack;
}
示例2: Folder
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Used to inflate the Workspace from XML.
*
* @param context The application's context.
* @param attrs The attributes set containing the Workspace's customization values.
*/
public Folder(Context context, AttributeSet attrs) {
super(context, attrs);
setAlwaysDrawnWithCacheEnabled(false);
Resources res = getResources();
mExpandDuration = res.getInteger(R.integer.config_folderExpandDuration);
mMaterialExpandDuration = res.getInteger(R.integer.config_materialFolderExpandDuration);
mMaterialExpandStagger = res.getInteger(R.integer.config_materialFolderExpandStagger);
if (sDefaultFolderName == null) {
sDefaultFolderName = res.getString(R.string.folder_name);
}
if (sHintText == null) {
sHintText = res.getString(R.string.folder_hint_text);
}
mLauncher = Launcher.getLauncher(context);
// We need this view to be focusable in touch mode so that when text editing of the folder
// name is complete, we have something to focus on, thus hiding the cursor and giving
// reliable behavior when clicking the text field (since it will always gain focus on click).
setFocusableInTouchMode(true);
}
示例3: UnderlinePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
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) {
setBackgroundDrawable(background);
}
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
示例4: CirclePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
public CirclePageIndicator(Context context, AttributeSet attrs) {
super(context, attrs);
if (isInEditMode()) return;
//Load defaults from resources
final Resources res = getResources();
final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);
mCentered = defaultCentered;
mOrientation = defaultOrientation;
mPaintPageFill.setStyle(Style.FILL);
mPaintPageFill.setColor(defaultPageColor);
mPaintStroke.setStyle(Style.STROKE);
mPaintStroke.setColor(defaultStrokeColor);
mPaintStroke.setStrokeWidth(defaultStrokeWidth);
mPaintFill.setStyle(Style.FILL);
mPaintFill.setColor(defaultFillColor);
mRadius = defaultRadius;
mSnap = defaultSnap;
/*
Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
}
*/
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
示例5: PhoneTabSwitcherLayout
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Creates a new layout, which implements the functionality of a {@link TabSwitcher} on
* smartphones.
*
* @param tabSwitcher
* The tab switcher, the layout belongs to, as an instance of the class {@link
* TabSwitcher}. The tab switcher may not be null
* @param model
* The model of the tab switcher, the layout belongs to, as an instance of the class
* {@link TabSwitcherModel}. The model may not be null
* @param arithmetics
* The arithmetics, which should be used by the layout, as an instance of the class
* {@link PhoneArithmetics}. The arithmetics may not be null
*/
public PhoneTabSwitcherLayout(@NonNull final TabSwitcher tabSwitcher,
@NonNull final TabSwitcherModel model,
@NonNull final PhoneArithmetics arithmetics) {
super(tabSwitcher, model, arithmetics);
Resources resources = tabSwitcher.getResources();
tabInset = resources.getDimensionPixelSize(R.dimen.tab_inset);
tabBorderWidth = resources.getDimensionPixelSize(R.dimen.tab_border_width);
tabTitleContainerHeight =
resources.getDimensionPixelSize(R.dimen.tab_title_container_height);
stackedTabCount = resources.getInteger(R.integer.stacked_tab_count);
stackedTabSpacing = resources.getDimensionPixelSize(R.dimen.stacked_tab_spacing);
maxCameraDistance = resources.getDimensionPixelSize(R.dimen.max_camera_distance);
TypedValue typedValue = new TypedValue();
resources.getValue(R.dimen.swiped_tab_scale, typedValue, true);
swipedTabScale = typedValue.getFloat();
resources.getValue(R.dimen.swiped_tab_alpha, typedValue, true);
swipedTabAlpha = typedValue.getFloat();
showSwitcherAnimationDuration =
resources.getInteger(R.integer.show_switcher_animation_duration);
hideSwitcherAnimationDuration =
resources.getInteger(R.integer.hide_switcher_animation_duration);
toolbarVisibilityAnimationDuration =
resources.getInteger(R.integer.toolbar_visibility_animation_duration);
toolbarVisibilityAnimationDelay =
resources.getInteger(R.integer.toolbar_visibility_animation_delay);
swipeAnimationDuration = resources.getInteger(R.integer.swipe_animation_duration);
clearAnimationDelay = resources.getInteger(R.integer.clear_animation_delay);
relocateAnimationDuration = resources.getInteger(R.integer.relocate_animation_duration);
relocateAnimationDelay = resources.getInteger(R.integer.relocate_animation_delay);
revertOvershootAnimationDuration =
resources.getInteger(R.integer.revert_overshoot_animation_duration);
revealAnimationDuration = resources.getInteger(R.integer.reveal_animation_duration);
peekAnimationDuration = resources.getInteger(R.integer.peek_animation_duration);
maxStartOvershootAngle = resources.getInteger(R.integer.max_start_overshoot_angle);
maxEndOvershootAngle = resources.getInteger(R.integer.max_end_overshoot_angle);
tabViewBottomMargin = -1;
toolbarAnimation = null;
}
示例6: CirclePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
//Load defaults from resources
final Resources res = getResources();
final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color);
final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color);
final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color);
final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width);
final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius);
final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered);
final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap);
//Retrieve styles attributes
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, 0);
mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered);
mOrientation = a.getInt(R.styleable.CirclePageIndicator_android_orientation, defaultOrientation);
mPaintPageFill.setStyle(Style.FILL);
mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor));
mPaintStroke.setStyle(Style.STROKE);
mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor));
mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth));
mPaintFill.setStyle(Style.FILL);
mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor));
mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius);
mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap);
Drawable background = a.getDrawable(R.styleable.CirclePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
示例7: computeAllAppsButtonSize
import android.content.res.Resources; //導入方法依賴的package包/類
/**
* Determine the exact visual footprint of the all apps button, taking into account scaling
* and internal padding of the drawable.
*/
private void computeAllAppsButtonSize(Context context) {
Resources res = context.getResources();
float padding = res.getInteger(R.integer.config_allAppsButtonPaddingPercent) / 100f;
allAppsButtonVisualSize = (int) (hotseatIconSizePx * (1 - padding)) - context.getResources()
.getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
}
示例8: updateIconSize
import android.content.res.Resources; //導入方法依賴的package包/類
private void updateIconSize(float scale, int drawablePadding, Resources res,
DisplayMetrics dm) {
iconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale);
iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale);
iconDrawablePaddingPx = drawablePadding;
hotseatIconSizePx = (int) (Utilities.pxFromDp(inv.hotseatIconSize, dm) * scale);
allAppsIconSizePx = iconSizePx;
allAppsIconDrawablePaddingPx = iconDrawablePaddingPx;
allAppsIconTextSizePx = iconTextSizePx;
cellWidthPx = iconSizePx;
cellHeightPx = iconSizePx + iconDrawablePaddingPx
+ Utilities.calculateTextHeight(iconTextSizePx);
// Hotseat
hotseatCellWidthPx = iconSizePx;
hotseatCellHeightPx = iconSizePx;
if (!isVerticalBarLayout()) {
int expectedWorkspaceHeight = availableHeightPx - hotseatBarHeightPx
- pageIndicatorHeightPx - topWorkspacePadding;
float minRequiredHeight = dropTargetBarSizePx + workspaceSpringLoadedBottomSpace;
workspaceSpringLoadShrinkFactor = Math.min(
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f,
1 - (minRequiredHeight / expectedWorkspaceHeight));
} else {
workspaceSpringLoadShrinkFactor =
res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f;
}
// Folder icon
folderBackgroundOffset = -edgeMarginPx;
folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
folderIconPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding);
}
示例9: getStyleColumnCount
import android.content.res.Resources; //導入方法依賴的package包/類
public int getStyleColumnCount(Context context, int style) {
Resources res = context.getResources();
boolean landscape = res.getBoolean(R.bool.landscape);
int styleColumnCount = getDefaultStyleColumnCount(context, style);
if (landscape &&
(style == res.getInteger(R.integer.STYLE_CARDS_VALUE) ||
style == res.getInteger(R.integer.STYLE_CARDS_2_VALUE))) {
return styleColumnCount + 1;
}
return styleColumnCount;
}
示例10: CirclePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
//Load defaults from resources
final Resources res = getResources();
final int defaultPageColor = res.getColor(R.color.lv_default_circle_indicator_page_color);
final int defaultFillColor = res.getColor(R.color.lv_default_circle_indicator_fill_color);
final int defaultOrientation = res.getInteger(R.integer.lv_default_circle_indicator_orientation);
final int defaultStrokeColor = res.getColor(R.color.lv_default_circle_indicator_stroke_color);
final float defaultStrokeWidth = res.getDimension(R.dimen.lv_default_circle_indicator_stroke_width);
final float defaultRadius = res.getDimension(R.dimen.lv_default_circle_indicator_radius);
final boolean defaultCentered = res.getBoolean(R.bool.lv_default_circle_indicator_centered);
final boolean defaultSnap = res.getBoolean(R.bool.lv_default_circle_indicator_snap);
//Retrieve styles attributes
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LVCirclePageIndicator, defStyle, 0);
mCentered = a.getBoolean(R.styleable.LVCirclePageIndicator_lv_centered1, defaultCentered);
mOrientation = a.getInt(R.styleable.LVCirclePageIndicator_android_orientation, defaultOrientation);
mPaintPageFill.setStyle(Style.FILL);
mPaintPageFill.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_pageColor, defaultPageColor));
mPaintStroke.setStyle(Style.STROKE);
mPaintStroke.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_strokeColor, defaultStrokeColor));
mPaintStroke.setStrokeWidth(a.getDimension(R.styleable.LVCirclePageIndicator_lv_strokeWidth, defaultStrokeWidth));
mPaintFill.setStyle(Style.FILL);
mPaintFill.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_fillColor, defaultFillColor));
mRadius = a.getDimension(R.styleable.LVCirclePageIndicator_lv_radius1, defaultRadius);
mSnap = a.getBoolean(R.styleable.LVCirclePageIndicator_lv_snap, defaultSnap);
Drawable background = a.getDrawable(R.styleable.LVCirclePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
示例11: getStyleGridSpacing
import android.content.res.Resources; //導入方法依賴的package包/類
public int getStyleGridSpacing(Context context, int style) {
Resources res = context.getResources();
if (style == res.getInteger(R.integer.STYLE_CARDS_VALUE)) {
return (int) res.getDimension(R.dimen.cards_style_grid_spacing);
}
return 0;
}
示例12: getStyle
import android.content.res.Resources; //導入方法依賴的package包/類
public int getStyle(Context context, boolean pickPhotos) {
Resources res = context.getResources();
if (pickPhotos && style == res.getInteger(R.integer.STYLE_NESTED_RECYCLER_VIEW_VALUE)) {
return res.getInteger(R.integer.STYLE_CARDS_VALUE);
}
return style;
}
示例13: TitlePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mCurrentPage = -1;
this.mPaintText = new Paint();
this.mPath = new Path();
this.mBounds = new Rect();
this.mPaintFooterLine = new Paint();
this.mPaintFooterIndicator = new Paint();
this.mLastMotionX = -1.0f;
this.mActivePointerId = -1;
if (!isInEditMode()) {
Resources res = getResources();
int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
float defaultFooterLineHeight = res.getDimension(R.dimen
.default_title_indicator_footer_line_height);
int defaultFooterIndicatorStyle = res.getInteger(R.integer
.default_title_indicator_footer_indicator_style);
float defaultFooterIndicatorHeight = res.getDimension(R.dimen
.default_title_indicator_footer_indicator_height);
float defaultFooterIndicatorUnderlinePadding = res.getDimension(R.dimen
.default_title_indicator_footer_indicator_underline_padding);
float defaultFooterPadding = res.getDimension(R.dimen
.default_title_indicator_footer_padding);
int defaultLinePosition = res.getInteger(R.integer
.default_title_indicator_line_position);
int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
boolean defaultSelectedBold = res.getBoolean(R.bool
.default_title_indicator_selected_bold);
int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
float defaultTitlePadding = res.getDimension(R.dimen
.default_title_indicator_title_padding);
float defaultClipPadding = res.getDimension(R.dimen
.default_title_indicator_clip_padding);
float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator,
defStyle, 0);
this.mFooterLineHeight = a.getDimension(6, defaultFooterLineHeight);
this.mFooterIndicatorStyle = IndicatorStyle.fromValue(a.getInteger(7,
defaultFooterIndicatorStyle));
this.mFooterIndicatorHeight = a.getDimension(8, defaultFooterIndicatorHeight);
this.mFooterIndicatorUnderlinePadding = a.getDimension(9,
defaultFooterIndicatorUnderlinePadding);
this.mFooterPadding = a.getDimension(10, defaultFooterPadding);
this.mLinePosition = LinePosition.fromValue(a.getInteger(11, defaultLinePosition));
this.mTopPadding = a.getDimension(14, defaultTopPadding);
this.mTitlePadding = a.getDimension(13, defaultTitlePadding);
this.mClipPadding = a.getDimension(4, defaultClipPadding);
this.mColorSelected = a.getColor(3, defaultSelectedColor);
this.mColorText = a.getColor(1, defaultTextColor);
this.mBoldText = a.getBoolean(12, defaultSelectedBold);
float textSize = a.getDimension(0, defaultTextSize);
int footerColor = a.getColor(5, defaultFooterColor);
this.mPaintText.setTextSize(textSize);
this.mPaintText.setAntiAlias(true);
this.mPaintFooterLine.setStyle(Style.FILL_AND_STROKE);
this.mPaintFooterLine.setStrokeWidth(this.mFooterLineHeight);
this.mPaintFooterLine.setColor(footerColor);
this.mPaintFooterIndicator.setStyle(Style.FILL_AND_STROKE);
this.mPaintFooterIndicator.setColor(footerColor);
Drawable background = a.getDrawable(2);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration
.get(context));
}
}
示例14: TitlePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
//Load defaults from resources
final Resources res = getResources();
final int defaultFooterColor = res.getColor(R.color.default_title_indicator_footer_color);
final float defaultFooterLineHeight = res.getDimension(R.dimen.default_title_indicator_footer_line_height);
final int defaultFooterIndicatorStyle = res.getInteger(R.integer.default_title_indicator_footer_indicator_style);
final float defaultFooterIndicatorHeight = res.getDimension(R.dimen.default_title_indicator_footer_indicator_height);
final float defaultFooterIndicatorUnderlinePadding = res.getDimension(R.dimen.default_title_indicator_footer_indicator_underline_padding);
final float defaultFooterPadding = res.getDimension(R.dimen.default_title_indicator_footer_padding);
final int defaultLinePosition = res.getInteger(R.integer.default_title_indicator_line_position);
final int defaultSelectedColor = res.getColor(R.color.default_title_indicator_selected_color);
final boolean defaultSelectedBold = res.getBoolean(R.bool.default_title_indicator_selected_bold);
final int defaultTextColor = res.getColor(R.color.default_title_indicator_text_color);
final float defaultTextSize = res.getDimension(R.dimen.default_title_indicator_text_size);
final float defaultTitlePadding = res.getDimension(R.dimen.default_title_indicator_title_padding);
final float defaultClipPadding = res.getDimension(R.dimen.default_title_indicator_clip_padding);
final float defaultTopPadding = res.getDimension(R.dimen.default_title_indicator_top_padding);
//Retrieve styles attributes
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, 0);
//Retrieve the colors to be used for this view and apply them.
mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);
mFooterIndicatorStyle = IndicatorStyle.fromValue(a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle));
mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight);
mFooterIndicatorUnderlinePadding = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding);
mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding);
mLinePosition = LinePosition.fromValue(a.getInteger(R.styleable.TitlePageIndicator_linePosition, defaultLinePosition));
mTopPadding = a.getDimension(R.styleable.TitlePageIndicator_topPadding, defaultTopPadding);
mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding);
mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding);
mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor);
mColorText = a.getColor(R.styleable.TitlePageIndicator_android_textColor, defaultTextColor);
mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold);
final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize);
final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor);
mPaintText.setTextSize(textSize);
mPaintText.setAntiAlias(true);
mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
mPaintFooterLine.setStrokeWidth(mFooterLineHeight);
mPaintFooterLine.setColor(footerColor);
mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE);
mPaintFooterIndicator.setColor(footerColor);
Drawable background = a.getDrawable(R.styleable.TitlePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
示例15: UnderlinePageIndicator
import android.content.res.Resources; //導入方法依賴的package包/類
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mPaint = new Paint(1);
this.mLastMotionX = -1.0f;
this.mActivePointerId = -1;
this.mFadeRunnable = new Runnable() {
public void run() {
if (UnderlinePageIndicator.this.mFades) {
int alpha = Math.max(UnderlinePageIndicator.this.mPaint.getAlpha() -
UnderlinePageIndicator.this.mFadeBy, 0);
UnderlinePageIndicator.this.mPaint.setAlpha(alpha);
UnderlinePageIndicator.this.invalidate();
if (alpha > 0) {
UnderlinePageIndicator.this.postDelayed(this, 30);
}
}
}
};
if (!isInEditMode()) {
Resources res = getResources();
boolean defaultFades = res.getBoolean(R.bool.default_underline_indicator_fades);
int defaultFadeDelay = res.getInteger(R.integer.default_underline_indicator_fade_delay);
int defaultFadeLength = res.getInteger(R.integer
.default_underline_indicator_fade_length);
int defaultSelectedColor = res.getColor(R.color
.default_underline_indicator_selected_color);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable
.UnderlinePageIndicator, defStyle, 0);
setFades(a.getBoolean(2, defaultFades));
setSelectedColor(a.getColor(1, defaultSelectedColor));
setFadeDelay(a.getInteger(3, defaultFadeDelay));
setFadeLength(a.getInteger(4, defaultFadeLength));
Drawable background = a.getDrawable(0);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
this.mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(ViewConfiguration
.get(context));
}
}