List of usage examples for android.content.res Resources getColor
@ColorInt @Deprecated public int getColor(@ColorRes int id) throws NotFoundException
From source file:com.superchat.date.MonthView.java
public MonthView(Context context, AttributeSet attr) { super(context, attr); Resources res = context.getResources(); mDayLabelCalendar = Calendar.getInstance(); mCalendar = Calendar.getInstance(); mDayOfWeekTypeface = res.getString(R.string.day_of_week_label_typeface); mMonthTitleTypeface = res.getString(R.string.sans_serif); mDayTextColor = res.getColor(R.color.date_picker_text_normal); mTodayNumberColor = res.getColor(R.color.blue); mDisabledDayTextColor = res.getColor(R.color.date_picker_text_disabled); mMonthTitleColor = res.getColor(android.R.color.white); mMonthTitleBGColor = res.getColor(R.color.circle_background); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); MINI_DAY_NUMBER_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.day_number_size); MONTH_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_label_size); MONTH_DAY_LABEL_TEXT_SIZE = res.getDimensionPixelSize(R.dimen.month_day_label_text_size); MONTH_HEADER_SIZE = res.getDimensionPixelOffset(R.dimen.month_list_item_header_height); DAY_SELECTED_CIRCLE_SIZE = res.getDimensionPixelSize(R.dimen.day_number_select_circle_radius); mRowHeight = (res.getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - getMonthHeaderSize()) / MAX_NUM_ROWS;// ww w. ja va 2s . c o m // Set up accessibility components. mTouchHelper = getMonthViewTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); mLockAccessibilityDelegate = true; // Sets up any standard paints that will be used initView(); }
From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_session_livestream); mIsTablet = UIUtils.isTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerFragment) getFragmentManager().findFragmentById(R.id.livestream_player); mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this); // Views that are common over all layouts mMainLayout = (LinearLayout) findViewById(R.id.livestream_mainlayout); adjustMainLayoutForActionBar();//from w w w. ja va 2s . com mPlayerContainer = (LinearLayout) findViewById(R.id.livestream_player_container); mFullscreenCaptions = (FrameLayout) findViewById(R.id.fullscreen_captions); final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams(); params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx()); mFullscreenCaptions.setLayoutParams(params); mTabsContentLayout = (LinearLayout) findViewById(R.id.livestream_tabs_layout); // Set up ViewPager and adapter ViewPager viewPager = (ViewPager) findViewById(R.id.livestream_pager); viewPager.setOffscreenPageLimit(2); viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width)); mTabsAdapter = new TabsAdapter(getFragmentManager()); viewPager.setAdapter(mTabsAdapter); viewPager.setOnPageChangeListener(mTabsAdapter); if (mIsTablet) { // Tablet UI specific views mVideoLayout = (LinearLayout) findViewById(R.id.livestream_video_layout); } mTabsAdapter.addTab(getString(R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); mTabsAdapter.addTab(getString(R.string.session_livestream_captions), new SessionCaptionsFragment(), TABNUM_LIVE_CAPTIONS); // Set up sliding tabs w/ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.livestream_sliding_tabs); slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); Resources res = getResources(); slidingTabLayout.setSelectedIndicatorColors(res.getColor(R.color.tab_selected_strip)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); // Reload all other data in this activity reloadFromIntent(getIntent()); // Update layout based on current configuration updateLayout(getResources().getConfiguration()); // Set up action bar if (!mLoadFromExtras) { // Start sessions query to populate action bar navigation spinner getLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); mLivestreamAdapter = new LivestreamAdapter(getActionBar().getThemedContext()); } }
From source file:com.example.anumbrella.viewpager.UnderlinePagerIndicator.java
public UnderlinePagerIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); ////from ww w . j av a 2 s . c om if (isInEditMode()) { return; } //?? final Resources res = getResources(); // //? 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); //?xml TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.UnderlinePagerIndicator, defStyle, 0); setFades(array.getBoolean(R.styleable.UnderlinePagerIndicator_fades, defaultFades)); setSelectedColor(array.getColor(R.styleable.UnderlinePagerIndicator_selectedColor, defaultSelectedColor)); setFadeDelay(array.getInteger(R.styleable.UnderlinePagerIndicator_fadeDelay, defaultFadeDelay)); setFadeLength(array.getInteger(R.styleable.UnderlinePagerIndicator_fadeLength, defaultFadeLength)); Drawable background = array.getDrawable(R.styleable.UnderlinePagerIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } array.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); //????(?????) mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.sina.android.weibo.sdk.widget.LoginoutButton.java
/** * ??//www . jav a 2s . c om * * @param attrs XML ? */ private void loadDefaultStyle(AttributeSet attrs) { if (attrs != null && 0 == attrs.getStyleAttribute()) { Resources res = getResources(); this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue); this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom)); this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0); this.setCompoundDrawablePadding( res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding)); this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size)); this.setTypeface(Typeface.DEFAULT_BOLD); this.setGravity(Gravity.CENTER); this.setText(R.string.com_sina_weibo_sdk_login_with_weibo_account); } }
From source file:com.sina.weibo.sdk.widget.LoginButton1.java
/** * // ww w .j a v a 2 s. com * * @param attrs XML */ private void loadDefaultStyle(AttributeSet attrs) { if (attrs != null && 0 == attrs.getStyleAttribute()) { Resources res = getResources(); this.setBackgroundResource(R.drawable.com_sina_weibo_sdk_button_blue); this.setPadding(res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_left), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_top), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_right), res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_padding_bottom)); this.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_com_sina_weibo_sdk_logo, 0, 0, 0); this.setCompoundDrawablePadding( res.getDimensionPixelSize(R.dimen.com_sina_weibo_sdk_loginview_compound_drawable_padding)); this.setTextColor(res.getColor(R.color.com_sina_weibo_sdk_loginview_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, res.getDimension(R.dimen.com_sina_weibo_sdk_loginview_text_size)); this.setTypeface(Typeface.DEFAULT_BOLD); this.setGravity(Gravity.CENTER); this.setText(R.string.com_sina_weibo_sdk_login_withweb); } }
From source file:com.android.mms.quickmessage.QuickMessagePopup.java
private void setupViews() { // Load the main views mQmPagerArrow = (ImageView) findViewById(R.id.pager_arrow); mQmMessageCounter = (TextView) findViewById(R.id.message_counter); mCloseButton = (Button) findViewById(R.id.button_close); mViewButton = (Button) findViewById(R.id.button_view); // Set the theme color on the pager arrow Resources res = getResources(); if (mDarkTheme) { mQmPagerArrow.setBackgroundColor(res.getColor(R.color.quickmessage_body_dark_bg)); } else {//from w w w . j av a 2s . co m mQmPagerArrow.setBackgroundColor(res.getColor(R.color.quickmessage_body_light_bg)); } // ViewPager Support mPagerAdapter = new MessagePagerAdapter(); mMessagePager = (ViewPager) findViewById(R.id.message_pager); mMessagePager.setAdapter(mPagerAdapter); mMessagePager.setOnPageChangeListener(mPagerAdapter); // Close button mCloseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // If not closing all, close the current QM and move on int numMessages = mMessageList.size(); if (mCloseClosesAll || numMessages == 1) { clearNotification(true); finish(); } else { // Dismiss the keyboard if it is shown QuickMessage qm = mMessageList.get(mCurrentPage); if (qm != null) { dismissKeyboard(qm); if (mCurrentPage < numMessages - 1) { showNextMessageWithRemove(qm); } else { showPreviousMessageWithRemove(qm); } } } } }); // View button mViewButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Override the re-lock if the screen was unlocked if (mScreenUnlocked) { // Cancel the receiver that will clear the wake locks ClearAllReceiver.removeCancel(getApplicationContext()); ClearAllReceiver.clearAll(false); mScreenUnlocked = false; } // Trigger the view intent mCurrentQm = mMessageList.get(mCurrentPage); Intent vi = mCurrentQm.getViewIntent(); if (vi != null) { mCurrentQm.saveReplyText(); vi.putExtra("sms_body", mCurrentQm.getReplyText()); startActivity(vi); } clearNotification(false); finish(); } }); }
From source file:anabolicandroids.chanobol.util.swipebottom.SwipeRefreshLayoutBottom.java
/** * Set the color resources used in the progress animation from color resources. * The first color will also be the color of the bar that grows in response * to a user swipe gesture.//from ww w . ja v a2s .co m * * @param colorResIds */ public void setColorSchemeResources(int... colorResIds) { final Resources res = getResources(); int[] colorRes = new int[colorResIds.length]; for (int i = 0; i < colorResIds.length; i++) { colorRes[i] = res.getColor(colorResIds[i]); } setColorSchemeColors(colorRes); }
From source file:com.pdmanager.views.patient.TechnicianActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {/*from w ww.j a va2 s . co m*/ Resources resources = getResources(); ColorDrawable bgColorPrimary = new ColorDrawable(resources.getColor(R.color.primary_title_background)); ColorDrawable bgColorSecondary = new ColorDrawable( resources.getColor(R.color.secondary_title_background)); currentBgColor = bgColorPrimary; setContentView(R.layout.activity_technician); Toolbar tb = (Toolbar) this.findViewById(R.id.toolbar); this.setSupportActionBar(tb); tb.setTitleTextColor(Color.WHITE); actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setBackgroundDrawable(currentBgColor); } this.setupActionBar(); } catch (Exception ex) { } //RecordingSettingsHandler.getInstance().Init(getApplicationContext()); app = (PDPilotAppContext) this.getApplicationContext(); // this.tipsPresenter = com.telerik.android.common.Util.getLayoutPart(this, R.id.tipsPresenter, TipsPresenter.class); try { this.setupNavigationDrawer(savedInstanceState); } catch (Exception e) { } try { // Prevents the drawer from being opened at the time of the first launch. //com.telerik.android.common.Util.getLayoutPart(this, R.id.drawer_layout, DrawerLayout.class).closeDrawer(Gravity.LEFT); this.getSupportFragmentManager().addOnBackStackChangedListener(this); if (savedInstanceState == null) { this.loadSectionFromIntent(this.getIntent(), false); // this.app.trackScreenOpened(this); } } catch (Exception e) { } }
From source file:com.home.library.vpi.TitlePageIndicator.java
public TitlePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;// ww w . ja va 2s. co m //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); final int defaultBackGroundColor = res.getColor(R.color.default_title_background_color); final boolean defaultFades = res.getBoolean(R.bool.default_title_indicator_fades); final int defaultFadeDelay = res.getInteger(R.integer.default_title_indicator_fade_delay); final int defaultFadeLength = res.getInteger(R.integer.default_title_indicator_fade_length); //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); mBackGroundColor = a.getColor(R.styleable.TitlePageIndicator_titleBackGround, defaultBackGroundColor); final float textSize = a.getDimension(R.styleable.TitlePageIndicator_android_textSize, defaultTextSize); mFooterColor = a.getColor(R.styleable.TitlePageIndicator_footerColor, defaultFooterColor); mPaintText.setTextSize(textSize); mPaintText.setAntiAlias(true); mPaintText.setColor(mColorText); mPaintText.setAlpha(0xFF); mPaintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterLine.setStrokeWidth(mFooterLineHeight); mPaintFooterLine.setColor(mFooterColor); mPaintFooterIndicator.setStyle(Paint.Style.FILL_AND_STROKE); mPaintFooterIndicator.setColor(mFooterColor); mBackGroundPaint.setColor(mBackGroundColor); mInitBackGroundPaintAlpha = mBackGroundPaint.getAlpha(); setFades(a.getBoolean(R.styleable.TitlePageIndicator_titleFades, defaultFades)); setFadeDelay(a.getInteger(R.styleable.TitlePageIndicator_titleFadeDelay, defaultFadeDelay)); setFadeLength(a.getInteger(R.styleable.TitlePageIndicator_titleFadeLength, defaultFadeLength)); 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); }
From source file:com.saarang.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(com.saarang.samples.apps.iosched.R.layout.activity_session_livestream); mIsTablet = UIUtils.isTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerFragment) getFragmentManager() .findFragmentById(com.saarang.samples.apps.iosched.R.id.livestream_player); mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this); // Views that are common over all layouts mMainLayout = (LinearLayout) findViewById(com.saarang.samples.apps.iosched.R.id.livestream_mainlayout); adjustMainLayoutForActionBar();/*from w w w.j a v a2s .c om*/ mPlayerContainer = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_player_container); mFullscreenCaptions = (FrameLayout) findViewById(com.saarang.samples.apps.iosched.R.id.fullscreen_captions); final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams(); params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx()); mFullscreenCaptions.setLayoutParams(params); mTabsContentLayout = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_tabs_layout); // Set up ViewPager and adapter ViewPager viewPager = (ViewPager) findViewById(com.saarang.samples.apps.iosched.R.id.livestream_pager); viewPager.setOffscreenPageLimit(2); viewPager.setPageMargin( getResources().getDimensionPixelSize(com.saarang.samples.apps.iosched.R.dimen.page_margin_width)); mTabsAdapter = new TabsAdapter(getFragmentManager()); viewPager.setAdapter(mTabsAdapter); viewPager.setOnPageChangeListener(mTabsAdapter); if (mIsTablet) { // Tablet UI specific views mVideoLayout = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_video_layout); } mTabsAdapter.addTab(getString(com.saarang.samples.apps.iosched.R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); mTabsAdapter.addTab(getString(com.saarang.samples.apps.iosched.R.string.session_livestream_captions), new SessionCaptionsFragment(), TABNUM_LIVE_CAPTIONS); // Set up sliding tabs w/ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_sliding_tabs); slidingTabLayout.setCustomTabView(com.saarang.samples.apps.iosched.R.layout.tab_indicator, android.R.id.text1); Resources res = getResources(); slidingTabLayout.setSelectedIndicatorColors( res.getColor(com.saarang.samples.apps.iosched.R.color.tab_selected_strip)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); // Reload all other data in this activity reloadFromIntent(getIntent()); // Update layout based on current configuration updateLayout(getResources().getConfiguration()); // Set up action bar if (!mLoadFromExtras) { // Start sessions query to populate action bar navigation spinner getLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); mLivestreamAdapter = new LivestreamAdapter(getActionBar().getThemedContext()); } }