List of usage examples for android.content.res Resources getDimension
public float getDimension(@DimenRes int id) throws NotFoundException
From source file:joshuatee.wx.StormReportsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); preferences = PreferenceManager.getDefaultSharedPreferences(this); theme_blue_current = preferences.getString("THEME_BLUE", ""); if (theme_blue_current.contains("white")) { highlight_color = Color.BLUE; background_color = Color.BLACK; highlight_color_str = "blue"; background_color_str = "black"; }//www . ja v a2 s . c o m setTheme(Utility.Theme(theme_blue_current)); setContentView(R.layout.activity_storm_reports); //padding = (int)res.getDimension(R.dimen.padding); //padding_vertical = (int)res.getDimension(R.dimen.padding_vertical); Resources res = getResources(); padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) res.getDimension(R.dimen.padding), getResources().getDisplayMetrics()); padding_vertical = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) res.getDimension(R.dimen.padding_vertical), getResources().getDisplayMetrics()); text_size = res.getDimension(R.dimen.listitem_text); iv = new TouchImageView2(getBaseContext()); no = getIntent().getStringExtra(NO); dm = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(dm); final Calendar cal = Calendar.getInstance(); pYear = cal.get(Calendar.YEAR); pMonth = cal.get(Calendar.MONTH); pDay = cal.get(Calendar.DAY_OF_MONTH); // FIXME, handle first of the month if (no.equals("yesterday")) pDay--; cYear = pYear; cMonth = pMonth; cDay = pDay; UpdateIowaMesoData(); img_url = "http://www.spc.noaa.gov/climo/reports/" + no + ".gif"; text_url = "http://www.spc.noaa.gov/climo/reports/" + no + ".csv"; comma = Pattern.compile(","); br = Pattern.compile("<br>"); output = new StringBuilder(200); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, state_array)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Resources res = this.getResources(); mGrid.setColumnWidthFromLayout(R.layout.combo_bookmark_thumbnail); int paddingTop = (int) res.getDimension(R.dimen.combo_paddingTop); mRoot.setPadding(0, paddingTop, 0, 0); this.invalidateOptionsMenu(); }
From source file:com.cyou.cma.clockscreen.widget.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;//from w w w . ja v a 2 s. c o m final Resources res = getResources(); mDrawableUnselected = res.getDrawable(R.drawable.indicator_normal); mDrawableSelected = res.getDrawable(R.drawable.indicator_selected); // 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 = defaultCentered; mLineWidth = defaultLineWidth; mGapWidth = defaultGapWidth; setStrokeWidth(defaultStrokeWidth); mPaintUnselected.setColor(defaultUnselectedColor); mPaintSelected.setColor(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); }
From source file:com.aksalj.viewpagerslideshow.LinePageIndicator.java
public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from ww w . java 2s . co m*/ final Resources res = getResources(); //Load defaults from resources final int defaultLineStyle = res.getInteger(R.integer.default_line_style); 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); mBoxStyle = a.getInt(R.styleable.LinePageIndicator_lineStyle, defaultLineStyle) == 1; mCentered = a.getBoolean(R.styleable.LinePageIndicator_centered, mBoxStyle ? false : defaultCentered); mLineWidth = a.getDimension(R.styleable.LinePageIndicator_lineWidth, defaultLineWidth); mGapWidth = a.getDimension(R.styleable.LinePageIndicator_gapWidth, mBoxStyle ? 0.0f : 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); }
From source file:com.jakewharton.android.viewpagerindicator.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //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 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); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);/*w w w.java 2s . com*/ 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); 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_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }
From source file:com.stasbar.knowyourself.timer.CountingTimerView.java
public CountingTimerView(Context context, AttributeSet attrs) { super(context, attrs); mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE); Resources r = context.getResources(); mDefaultColor = mWhiteColor = ContextCompat.getColor(context, R.color.colorPrimary); mPressedColor = mAccentColor = ContextCompat.getColor(context, R.color.colorPrimary); mBigFontSize = r.getDimension(R.dimen.big_font_size); mSmallFontSize = r.getDimension(R.dimen.small_font_size); mPaintBigThin.setAntiAlias(true);//from w w w. j a va 2s .c o m mPaintBigThin.setStyle(Paint.Style.STROKE); mPaintBigThin.setTextAlign(Paint.Align.CENTER); mPaintBigThin.setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL)); mPaintMed.setAntiAlias(true); mPaintMed.setStyle(Paint.Style.STROKE); mPaintMed.setTextAlign(Paint.Align.CENTER); mPaintMed.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL)); resetTextSize(); setTextColor(mDefaultColor); // allDigits will contain ten digits: "0123456789" in the default locale final String allDigits = String.format(Locale.getDefault(), "%010d", 123456789); mBigSeconds = new UnsignedTime(mPaintBigThin, 0.f, allDigits); mBigHours = new SignedTime(mBigSeconds, HOURS_MINUTES_SPACING); mBigMinutes = new SignedTime(mBigSeconds, HOURS_MINUTES_SPACING); mMedHundredths = new Hundredths(mPaintMed, HUNDREDTHS_SPACING, allDigits); mRadiusOffset = Utils.calculateRadiusOffset(r); }
From source file:com.maedi.user.godok.v1.viewpagerindicator.LinePageIndicator.java
@SuppressWarnings("deprecation") public LinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// w w w. j a v a2 s . c o m final Resources res = getResources(); //Load defaults from resources final int defaultSelectedColor = res .getColor(com.viewpagerindicator.R.color.default_line_indicator_selected_color); final int defaultUnselectedColor = res .getColor(com.viewpagerindicator.R.color.default_line_indicator_unselected_color); final float defaultLineWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_line_indicator_line_width); final float defaultGapWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_line_indicator_gap_width); final float defaultStrokeWidth = res .getDimension(com.viewpagerindicator.R.dimen.default_line_indicator_stroke_width); final boolean defaultCentered = res .getBoolean(com.viewpagerindicator.R.bool.default_line_indicator_centered); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, com.viewpagerindicator.R.styleable.LinePageIndicator, defStyle, 0); mCentered = a.getBoolean(com.viewpagerindicator.R.styleable.LinePageIndicator_centered, defaultCentered); mLineWidth = a.getDimension(com.viewpagerindicator.R.styleable.LinePageIndicator_lineWidth, defaultLineWidth); mGapWidth = a.getDimension(com.viewpagerindicator.R.styleable.LinePageIndicator_gapWidth, defaultGapWidth); setStrokeWidth(a.getDimension(com.viewpagerindicator.R.styleable.LinePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintUnselected.setColor(a.getColor(com.viewpagerindicator.R.styleable.LinePageIndicator_unselectedColor, defaultUnselectedColor)); mPaintSelected.setColor(a.getColor(com.viewpagerindicator.R.styleable.LinePageIndicator_selectedColor, defaultSelectedColor)); Drawable background = a .getDrawable(com.viewpagerindicator.R.styleable.LinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:org.chromium.chrome.browser.download.DownloadNotificationService.java
private Bitmap getLargeNotificationIcon(Bitmap bitmap) { Resources resources = mContext.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); final OvalShape circle = new OvalShape(); circle.resize(width, height);/*from w ww. ja va 2 s . c o m*/ final Paint paint = new Paint(); paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500)); final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(result); circle.draw(canvas, paint); float leftOffset = (width - bitmap.getWidth()) / 2f; float topOffset = (height - bitmap.getHeight()) / 2f; if (leftOffset >= 0 && topOffset >= 0) { canvas.drawBitmap(bitmap, leftOffset, topOffset, null); } else { // Scale down the icon into the notification icon dimensions canvas.drawBitmap(bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), new Rect(0, 0, width, height), null); } return result; }
From source file:com.fanfou.app.opensource.ui.viewpager.TitlePageIndicator.java
public TitlePageIndicator(final Context context, final AttributeSet attrs, final int defStyle) { super(context, attrs, defStyle); // 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 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); // Retrieve styles attributes final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TitlePageIndicator, defStyle, R.style.Widget_TitlePageIndicator); // Retrieve the colors to be used for this view and apply them. this.mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);/*from www . ja v a 2 s. c om*/ this.mFooterIndicatorStyle = IndicatorStyle.fromValue( a.getInteger(R.styleable.TitlePageIndicator_footerIndicatorStyle, defaultFooterIndicatorStyle)); this.mFooterIndicatorHeight = a.getDimension(R.styleable.TitlePageIndicator_footerIndicatorHeight, defaultFooterIndicatorHeight); this.mFooterIndicatorUnderlinePadding = a.getDimension( R.styleable.TitlePageIndicator_footerIndicatorUnderlinePadding, defaultFooterIndicatorUnderlinePadding); this.mFooterPadding = a.getDimension(R.styleable.TitlePageIndicator_footerPadding, defaultFooterPadding); this.mTitlePadding = a.getDimension(R.styleable.TitlePageIndicator_titlePadding, defaultTitlePadding); this.mClipPadding = a.getDimension(R.styleable.TitlePageIndicator_clipPadding, defaultClipPadding); this.mColorSelected = a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); this.mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); this.mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); this.mPaintText = new Paint(); this.mPaintText.setTextSize(textSize); this.mPaintText.setAntiAlias(true); this.mPaintFooterLine = new Paint(); this.mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); this.mPaintFooterLine.setStrokeWidth(this.mFooterLineHeight); this.mPaintFooterLine.setColor(footerColor); this.mPaintFooterIndicator = new Paint(); this.mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); this.mPaintFooterIndicator.setColor(footerColor); a.recycle(); this.mPath = new Path(); }
From source file:com.androtex.viewpagerindicator.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //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); @SuppressWarnings("unused") 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, R.style.Widget_TitlePageIndicator); //Retrieve the colors to be used for this view and apply them. mFooterLineHeight = a.getDimension(R.styleable.TitlePageIndicator_footerLineHeight, defaultFooterLineHeight);//w w w . j av a 2s .c om 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); 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 = 0; //a.getColor(R.styleable.TitlePageIndicator_selectedColor, defaultSelectedColor); mColorText = a.getColor(R.styleable.TitlePageIndicator_textColor, defaultTextColor); mBoldText = a.getBoolean(R.styleable.TitlePageIndicator_selectedBold, defaultSelectedBold); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_textSize, defaultTextSize); final int footerColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText = new Paint(); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintFooterLine = new Paint(); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(footerColor); mPaintFooterIndicator = new Paint(); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(footerColor); a.recycle(); }