下面列出了android.content.res.Resources#getDimension() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void createMapSnapshot(OfflineRegionDefinition definition,
MapSnapshotter.SnapshotReadyCallback callback) {
Resources resources = getResources();
int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
MapSnapshotter.Options options = new MapSnapshotter.Options(width, height);
options.withStyle(definition.getStyleURL());
options.withRegion(definition.getBounds());
mapSnapshotter = new MapSnapshotter(this, options);
mapSnapshotter.start(callback);
}
/**
* Returns the animator for the appear animation
*
* @param message The TextView of the Message
* @param action The Button of the action. May be null if no action is supplied
* @return
*/
private Animator getAppearAnimation(@NonNull TextView message, @Nullable Button action) {
Resources res = mActivity.getResources();
mFromAnimation = res.getDimension(R.dimen.snack_bar_height);
mToAnimation = res.getDimension(R.dimen.snack_bar_animation_position) - mSnackBarOffset;
int delay = res.getInteger(R.integer.snackbar_ui_delay);
if (hasTranslucentNavigationBar()) {
int resourceId = res.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) mToAnimation -= res.getDimensionPixelSize(resourceId);
}
AnimatorSet set = new AnimatorSet();
List<Animator> animations = new ArrayList<>();
set.setDuration(res.getInteger(R.integer.snackbar_appear_animation_length));
animations.add(ObjectAnimator.ofFloat(mSnackBarView, "translationY", mFromAnimation, mToAnimation));
ObjectAnimator messageAnim = ObjectAnimator.ofFloat(message, "alpha", 0.0f, 1.0f);
messageAnim.setStartDelay(delay);
animations.add(messageAnim);
if (action != null) {
ObjectAnimator actionAnim = ObjectAnimator.ofFloat(action, "alpha", 0.0f, 1.0f);
actionAnim.setStartDelay(delay);
animations.add(actionAnim);
}
set.playTogether(animations);
return set;
}
private static void initStatics(Context context) {
final Resources resources = context.getResources();
final DisplayMetrics metrics = resources.getDisplayMetrics();
final float density = metrics.density;
sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
sIconTextureWidth = sIconTextureHeight = sIconWidth;
sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
sGlowColorPressedPaint.setColor(0xffffc300);
sGlowColorFocusedPaint.setColor(0xffff8e00);
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0.2f);
sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
sDisabledPaint.setAlpha(0x88);
}
@Override
public void onCreate(SurfaceHolder holder) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "onCreate");
}
super.onCreate(holder);
/** Accepts tap events via WatchFaceStyle (setAcceptsTapEvents(true)). */
setWatchFaceStyle(new WatchFaceStyle.Builder(InteractiveWatchFaceService.this)
.setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
.setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
.setShowSystemUiTime(false)
.setAcceptsTapEvents(true)
.build());
Resources resources = InteractiveWatchFaceService.this.getResources();
mTextSpacingHeight = resources.getDimension(R.dimen.interactive_text_size);
mTextPaint = new Paint();
mTextPaint.setColor(mScreenTextColor);
mTextPaint.setTypeface(BOLD_TYPEFACE);
mTextPaint.setAntiAlias(true);
mTouchCommandTotal = 0;
mTouchCancelCommandTotal = 0;
mTapCommandTotal = 0;
mTouchCoordinateX = 0;
mTouchCoordinateX = 0;
}
@Override
public void onCreate(SurfaceHolder holder) {
super.onCreate(holder);
setWatchFaceStyle(new WatchFaceStyle.Builder(MyTapFace.this)
.setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
.setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
.setShowSystemUiTime(false)
.setAcceptsTapEvents(true) //turn on the tap events.
.build());
Resources resources = MyTapFace.this.getResources();
mYOffset = resources.getDimension(R.dimen.digital_y_offset);
mBackgroundPaint = new Paint();
mBackgroundPaint.setColor(resources.getColor(R.color.digital_background));
mTextPaint = new Paint();
mTextPaint = createTextPaint(resources.getColor(R.color.digital_text));
//for rec painting, mostly the same as text, except for fill/stroke
mRecPaint = new Paint();
mRecPaint = createTextPaint(resources.getColor(R.color.digital_text));
mRecPaint.setStyle(Paint.Style.STROKE);
mRecPaint.setStrokeWidth(strokewidth); //set the line size to be 5 "pixels".
mTime = new Time();
//initialize the rectangle for later use.
myRec = new Rect();
}
public void attachToRecyclerView(@Nullable RecyclerView recyclerView) {
if (this.mRecyclerView != recyclerView) {
if (this.mRecyclerView != null) {
destroyCallbacks();
}
this.mRecyclerView = recyclerView;
if (this.mRecyclerView != null) {
Resources resources = recyclerView.getResources();
this.mSwipeEscapeVelocity = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_velocity);
this.mMaxSwipeVelocity = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_max_velocity);
setupCallbacks();
}
}
}
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);
}
/**
* Loads the styles and attributes defined in the xml tag of this class
*
* @param attributes The attributes to read from, do not pass {@link AttributeSet} as inflation needs the context of the {@link android.support.v4.view.PagerAdapter}
*/
public BarChartProgressView loadStyledAttributes(TypedArray attributes, ChartProgressAttr progress) {
mAttributes = attributes;
mChartProgressAttr = progress;
mIsFuture = progress == null ? false : progress.isFuture();
Resources res = getContext().getResources();
if (attributes != null) {
mCompletedColor = attributes.getColor(R.styleable.SlidePager_slide_progress_bar_chart_completed_color, res.getColor(R.color.default_progress_completed_reach_color));
mNotCompletedColor = attributes.getColor(R.styleable.SlidePager_slide_progress_bar_chart_not_completed_color, res.getColor(R.color.default_progress_not_completed_reach_color));
mFutureColor = attributes.getColor(R.styleable.SlidePager_slide_progress_bar_chart_future_color, res.getColor(R.color.default_progress_chart_bar_color));
mTodayColor = attributes.getColor(R.styleable.SlidePager_slide_progress_bar_chart_today_color, res.getColor(R.color.default_progress_special_reach_color));
mBarWidth = attributes.getDimension(R.styleable.SlidePager_slide_progress_bar_chart_bar_width, res.getDimension(R.dimen.bar_view_default_width));
mBarVisibleNullValue = attributes.getBoolean(R.styleable.SlidePager_slide_progress_bar_chart_null_value_bar_display, true);
mCheckMarkVisible = attributes.getBoolean(R.styleable.SlidePager_slide_progress_bar_chart_check_mark_visible, true);
mHasToReanimate = mAttributes.getBoolean(R.styleable.SlidePager_slide_pager_reanimate_slide_view, true);
//Do not recycle attributes, we need them for the future views
} else {
mCompletedColor = res.getColor(R.color.default_progress_completed_reach_color);
mNotCompletedColor = res.getColor(R.color.default_progress_not_completed_reach_color);
mFutureColor = res.getColor(R.color.default_progress_chart_bar_color);
mTodayColor = res.getColor(R.color.default_progress_special_reach_color);
mBarWidth = res.getDimension(R.dimen.bar_view_default_width);
mBarVisibleNullValue = true;
mCheckMarkVisible = true;
mHasToReanimate = true;
}
setBarColorsAndSize();
initAnimations();
return this;
}
/**
* Creates an instance of the {@link StripLayoutHelperManager}.
* @param context The current Android {@link Context}.
* @param updateHost The parent {@link LayoutUpdateHost}.
* @param renderHost The {@link LayoutRenderHost}.
*/
public StripLayoutHelperManager(Context context, LayoutUpdateHost updateHost,
LayoutRenderHost renderHost, AreaGestureEventFilter eventFilter) {
mUpdateHost = updateHost;
mTabStripTreeProvider = new TabStripSceneLayer(context);
mEventFilter = eventFilter;
mNormalHelper = new StripLayoutHelper(context, updateHost, renderHost, false);
mIncognitoHelper = new StripLayoutHelper(context, updateHost, renderHost, true);
mModelSelectorButton = new CompositorButton(
context, MODEL_SELECTOR_BUTTON_WIDTH_DP, MODEL_SELECTOR_BUTTON_HEIGHT_DP);
mModelSelectorButton.setIncognito(false);
mModelSelectorButton.setVisible(false);
// Pressed resources are the same as the unpressed resources.
mModelSelectorButton.setResources(R.drawable.btn_tabstrip_switch_normal,
R.drawable.btn_tabstrip_switch_normal, R.drawable.btn_tabstrip_switch_incognito,
R.drawable.btn_tabstrip_switch_incognito);
mModelSelectorButton.setY(MODEL_SELECTOR_BUTTON_Y_OFFSET_DP);
Resources res = context.getResources();
mHeight = res.getDimension(R.dimen.tab_strip_height) / res.getDisplayMetrics().density;
mModelSelectorButton.setAccessibilityDescription(
res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_standard),
res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_incognito));
onContextChanged(context);
}
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_radius1, 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);
}
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);
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
final Resources res = getResources();
//Load defaults from resources
final int defaultSelectedColor = res.getColor(R.color.default_line_indicator_selected_color);
final int defaultUnselectedColor = res.getColor(R.color.default_line_indicator_unselected_color);
final float defaultLineWidth = res.getDimension(R.dimen.default_line_indicator_line_width);
final float defaultGapWidth = res.getDimension(R.dimen.default_line_indicator_gap_width);
final float defaultStrokeWidth = res.getDimension(R.dimen.default_line_indicator_stroke_width);
final boolean defaultCentered = res.getBoolean(R.bool.default_line_indicator_centered);
//Retrieve styles attributes
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LinePageIndicator, defStyle, 0);
mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, defaultCentered);
mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth);
mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, defaultGapWidth);
setStrokeWidth(a.getDimension(R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth));
mPaintUnselected.setColor(a.getColor(R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor));
mPaintSelected.setColor(a.getColor(R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor));
Drawable background = a.getDrawable(R.styleable.LinePageIndicator_android_background);
if (background != null) {
setBackgroundDrawable(background);
}
a.recycle();
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration);
}
public Params(Resources res) {
TRANSLATION_PER_SEC = res.getDimension(R.dimen.translation_per_sec);
OBSTACLE_SPACING = res.getDimensionPixelSize(R.dimen.obstacle_spacing);
OBSTACLE_PERIOD = (int) (OBSTACLE_SPACING / TRANSLATION_PER_SEC);
BOOST_DV = res.getDimensionPixelSize(R.dimen.boost_dv);
PLAYER_HIT_SIZE = res.getDimensionPixelSize(R.dimen.player_hit_size);
PLAYER_SIZE = res.getDimensionPixelSize(R.dimen.player_size);
OBSTACLE_WIDTH = res.getDimensionPixelSize(R.dimen.obstacle_width);
OBSTACLE_STEM_WIDTH = res.getDimensionPixelSize(R.dimen.obstacle_stem_width);
OBSTACLE_GAP = res.getDimensionPixelSize(R.dimen.obstacle_gap);
OBSTACLE_MIN = res.getDimensionPixelSize(R.dimen.obstacle_height_min);
BUILDING_HEIGHT_MIN = res.getDimensionPixelSize(R.dimen.building_height_min);
BUILDING_WIDTH_MIN = res.getDimensionPixelSize(R.dimen.building_width_min);
BUILDING_WIDTH_MAX = res.getDimensionPixelSize(R.dimen.building_width_max);
CLOUD_SIZE_MIN = res.getDimensionPixelSize(R.dimen.cloud_size_min);
CLOUD_SIZE_MAX = res.getDimensionPixelSize(R.dimen.cloud_size_max);
STAR_SIZE_MIN = res.getDimensionPixelSize(R.dimen.star_size_min);
STAR_SIZE_MAX = res.getDimensionPixelSize(R.dimen.star_size_max);
G = res.getDimensionPixelSize(R.dimen.G);
MAX_V = res.getDimensionPixelSize(R.dimen.max_v);
SCENERY_Z = res.getDimensionPixelSize(R.dimen.scenery_z);
OBSTACLE_Z = res.getDimensionPixelSize(R.dimen.obstacle_z);
PLAYER_Z = res.getDimensionPixelSize(R.dimen.player_z);
PLAYER_Z_BOOST = res.getDimensionPixelSize(R.dimen.player_z_boost);
HUD_Z = res.getDimensionPixelSize(R.dimen.hud_z);
// Sanity checking
if (OBSTACLE_MIN <= OBSTACLE_WIDTH / 2) {
Mlog.e(TAG, "error: obstacles might be too short, adjusting");
OBSTACLE_MIN = OBSTACLE_WIDTH / 2 + 1;
}
}
/**
* Creates an instance of the {@link StripLayoutHelperManager}.
* @param context The current Android {@link Context}.
* @param updateHost The parent {@link LayoutUpdateHost}.
* @param renderHost The {@link LayoutRenderHost}.
*/
public StripLayoutHelperManager(
Context context, LayoutUpdateHost updateHost, LayoutRenderHost renderHost) {
mUpdateHost = updateHost;
mTabStripTreeProvider = new TabStripSceneLayer(context);
mTabStripEventHandler = new TabStripEventHandler();
mEventFilter =
new AreaGestureEventFilter(context, mTabStripEventHandler, null, false, false);
mNormalHelper = new StripLayoutHelper(context, updateHost, renderHost, false);
mIncognitoHelper = new StripLayoutHelper(context, updateHost, renderHost, true);
CompositorOnClickHandler selectorClickHandler = new CompositorOnClickHandler() {
@Override
public void onClick(long time) {
handleModelSelectorButtonClick();
}
};
mModelSelectorButton = new CompositorButton(context, MODEL_SELECTOR_BUTTON_WIDTH_DP,
MODEL_SELECTOR_BUTTON_HEIGHT_DP, selectorClickHandler);
mModelSelectorButton.setIncognito(false);
mModelSelectorButton.setVisible(false);
// Pressed resources are the same as the unpressed resources.
mModelSelectorButton.setResources(R.drawable.btn_tabstrip_switch_normal,
R.drawable.btn_tabstrip_switch_normal, R.drawable.btn_tabstrip_switch_incognito,
R.drawable.btn_tabstrip_switch_incognito);
mModelSelectorButton.setY(MODEL_SELECTOR_BUTTON_Y_OFFSET_DP);
Resources res = context.getResources();
mHeight = res.getDimension(R.dimen.tab_strip_height) / res.getDisplayMetrics().density;
mModelSelectorButton.setAccessibilityDescription(
res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_standard),
res.getString(R.string.accessibility_tabstrip_btn_incognito_toggle_incognito));
onContextChanged(context);
}
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);
}
public NewShowcaseDrawer(Resources resources) {
super(resources);
outerRadius = resources.getDimension(R.dimen.showcase_radius_outer);
innerRadius = resources.getDimension(R.dimen.showcase_radius_inner);
}
private static void initStatics(Context context) {
final Resources resources = context.getResources();
sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
}
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) return;
//Load defaults from resources
Resources res = getResources();
final int defaultPageColor = ContextCompat.getColor(getContext(), R.color.default_circle_indicator_page_color);
final int defaultFillColor = ContextCompat.getColor(getContext(), R.color.default_circle_indicator_fill_color);
final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation);
final int defaultStrokeColor = ContextCompat.getColor(getContext(), R.color.default_circle_indicator_stroke_color);
final float defaultExtraSpacing = res.getDimension(R.dimen.default_circle_indicator_extra_spacing);
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);
mExtraSpacing = a.getDimension(R.styleable.CirclePageIndicator_extraSpacing, defaultExtraSpacing);
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);
}
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);
}
/**
* Instantiates a new Footer decoration.
*
* @param resources the resources
*/
public FooterDecoration(Resources resources) {
mFooterPadding = (int) resources.getDimension(R.dimen.box_browsesdk_list_footer_padding);
}