List of usage examples for android.widget ImageView setColorFilter
public void setColorFilter(ColorFilter cf)
From source file:org.runbuddy.tomahawk.views.PageIndicator.java
private void updateColors(int position) { for (int i = 0; i < mItems.size(); i++) { TextView textView = (TextView) mItems.get(i).findViewById(R.id.textview); ImageView imageView = (ImageView) mItems.get(i).findViewById(R.id.imageview); ImageView arrow = (ImageView) mItems.get(i).findViewById(R.id.arrow); if (i == position) { textView.setTextColor(getResources().getColor(R.color.primary_textcolor_inverted)); imageView.clearColorFilter(); arrow.clearColorFilter();/*from w ww .ja v a2s .c o m*/ } else { textView.setTextColor(getResources().getColor(R.color.tertiary_textcolor_inverted)); ColorFilter grayOutFilter = new PorterDuffColorFilter( TomahawkApp.getContext().getResources().getColor(R.color.tertiary_textcolor_inverted), PorterDuff.Mode.MULTIPLY); imageView.setColorFilter(grayOutFilter); arrow.setColorFilter(grayOutFilter); } } }
From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) { if (isSeparator(itemId)) { // not applicable return;/*from w w w.j a v a 2 s . com*/ } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); // configure its appearance according to whether or not it's selected titleView.setTextColor(selected ? getResources().getColor(R.color.navdrawer_text_color_selected) : getResources().getColor(R.color.navdrawer_text_color)); iconView.setColorFilter(selected ? getResources().getColor(R.color.navdrawer_icon_tint_selected) : getResources().getColor(R.color.navdrawer_icon_tint)); }
From source file:com.woodblockwithoutco.quickcontroldock.ui.factory.ServiceViewFactory.java
@SuppressWarnings("deprecation") public View getServiceView() { boolean sameLayout = GeneralResolver.isSameLayoutForLandscape(mContext); int inflateId = 0; if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT || sameLayout) { inflateId = R.layout.panel_layout; } else {/*from w w w .j ava 2 s . c o m*/ inflateId = R.layout.panel_layout_land; } View view = LayoutInflater.from(mContext).inflate(inflateId, null, false); final DragViewGroup dragView = (DragViewGroup) view.findViewById(R.id.panel_drag_handler); dragView.setBackgroundDrawable(ColorsResolver.getBackgroundDrawable(mContext)); if (ConstantHolder.getIsDebug()) { initTestVersionText(dragView); } ViewGroup viewToHide; if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT || sameLayout) { LinearLayout panelsContainer = (LinearLayout) dragView.findViewById(R.id.panels_container); viewToHide = panelsContainer; if (ScreenUtils.getScreenOrientation(mContext) == Configuration.ORIENTATION_PORTRAIT) { panelsContainer.setTranslationY(GeneralResolver.getPanelsOffset(mContext)); } List<String> panelsOrder = PanelsOrderResolver.getPanelsOrder(mContext); if (ShortcutsResolver.isShortcutsEnabled(mContext)) { ShortcutsViewFactory svFactory = new ShortcutsViewFactory(mContext); int id = getContainerIdForPanelType(panelsOrder, PanelType.SHORTCUTS.name()); FrameLayout section = (FrameLayout) view.findViewById(id); adjustPanelMargins(section); section.addView(svFactory.getShortcutsSectionView()); } if (MusicResolver.isMusicPanelEnabled(mContext)) { MusicViewFactory mvFactory = new MusicViewFactory(mContext); int id = getContainerIdForPanelType(panelsOrder, PanelType.MUSIC.name()); FrameLayout section = (FrameLayout) view.findViewById(id); adjustPanelMargins(section); section.addView(mvFactory.getMusicView()); } if (TogglesResolver.isTogglesEnabled(mContext)) { TogglesViewFactory tvFactory = new TogglesViewFactory(mContext); int id = getContainerIdForPanelType(panelsOrder, PanelType.TOGGLES.name()); FrameLayout section = (FrameLayout) view.findViewById(id); adjustPanelMargins(section); section.addView(tvFactory.getTogglesSectionView()); } if (InfoResolver.isInfoPanelEnabled(mContext)) { InfoViewFactory ivFactory = new InfoViewFactory(mContext); int id = getContainerIdForPanelType(panelsOrder, PanelType.INFO.name()); FrameLayout section = (FrameLayout) view.findViewById(id); adjustPanelMargins(section); section.addView(ivFactory.getInfoView()); } if (NotificationsResolver.isNotificationsEnabled(mContext)) { final ImageView fakeNotificationsButton = (ImageView) dragView .findViewById(R.id.notifications_button_fake); PressImageView notificationsButton = (PressImageView) dragView .findViewById(R.id.notifications_button); fakeNotificationsButton.setVisibility(View.VISIBLE); notificationsButton.setVisibility(View.VISIBLE); fakeNotificationsButton.setImageResource(R.drawable.ic_notification_switch); fakeNotificationsButton.setColorFilter(ColorsResolver.getActiveColor(mContext)); final float SCALE = 1.5f; fakeNotificationsButton.setScaleX(SCALE); fakeNotificationsButton.setScaleY(SCALE); notificationsButton.setOnPressedStateChangeListener(new OnPressedStateChangeListener() { private final int BG_COLOR = ColorsResolver.getPressedColor(mContext); @Override public void onPressedStateChange(ImageView v, boolean pressed) { if (pressed) { fakeNotificationsButton.setBackgroundColor(BG_COLOR); } else { fakeNotificationsButton.setBackgroundColor(0x00000000); } } }); NotificationViewFactory nvFactory = new NotificationViewFactory(mContext); ViewGroup notificationsView = nvFactory.getNotificationsView(); notificationsView.setAlpha(0.0f); notificationsView.setVisibility(View.INVISIBLE); FrameLayout notificationsContainer = (FrameLayout) dragView .findViewById(R.id.notifications_section); notificationsContainer.addView(notificationsView); notificationsButton .setOnClickListener(new NotificationButtonClickListener(viewToHide, notificationsView)); } } else { ViewPager pager = (ViewPager) view.findViewById(R.id.landscape_pager); viewToHide = pager; List<View> views = new ArrayList<View>(); if (NotificationsResolver.isNotificationsEnabled(mContext)) { NotificationViewFactory nvFactory = new NotificationViewFactory(mContext); ViewGroup notificationsView = nvFactory.getNotificationsView(); views.add(notificationsView); } List<String> panelsOrder = PanelsOrderResolver.getPanelsOrder(mContext); for (String t : panelsOrder) { PanelType type = PanelType.valueOf(t); View v = null; FrameLayout container = (FrameLayout) LayoutInflater.from(mContext) .inflate(R.layout.panel_section_land, null, false); switch (type) { case INFO: // if (InfoResolver.isInfoPanelEnabled(mContext)) { InfoViewFactory ivFactory = new InfoViewFactory(mContext); FrameLayout fourthSection = (FrameLayout) view.findViewById(R.id.fourth_section); fourthSection.addView(ivFactory.getInfoView()); } break; case MUSIC: if (MusicResolver.isMusicPanelEnabled(mContext)) { MusicViewFactory mvFactory = new MusicViewFactory(mContext); v = mvFactory.getMusicView(); } break; case SHORTCUTS: if (ShortcutsResolver.isShortcutsEnabled(mContext)) { ShortcutsViewFactory svFactory = new ShortcutsViewFactory(mContext); v = svFactory.getShortcutsSectionView(); } break; case TOGGLES: if (TogglesResolver.isTogglesEnabled(mContext)) { TogglesViewFactory tvFactory = new TogglesViewFactory(mContext); v = tvFactory.getTogglesSectionView(); } break; } if (v != null) { views.add(v); container.addView(v); } } LandscapePanelsAdapter adapter = new LandscapePanelsAdapter(views); pager.setAdapter(adapter); pager.setOverScrollMode(View.OVER_SCROLL_NEVER); pager.setOffscreenPageLimit(VIEW_PAGER_OFFSCREEN_PAGES_COUNT); pager.setPageMargin(mContext.getResources().getDimensionPixelSize(R.dimen.pager_margin)); } return view; }
From source file:fr.shywim.antoinedaniel.ui.MainActivity.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) { if (isSeparator(itemId)) { return;//from ww w . j av a2 s . com } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); titleView.setTextColor(selected ? getResources().getColor(R.color.navdrawer_text_color_selected) : getResources().getColor(R.color.navdrawer_text_color)); iconView.setColorFilter(selected ? getResources().getColor(R.color.navdrawer_icon_tint_selected) : getResources().getColor(R.color.navdrawer_icon_tint)); }
From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java
private void setColor(ImageView imgView, IconColorIndicator colorIndicator) { imgView.clearColorFilter();//from w ww. j a va2 s .c o m if (colorIndicator == IconColorIndicator.Inactive) { return; } int color = -1; switch (colorIndicator) { case Bad: color = Color.parseColor("#FFEEEE"); break; case Good: color = ContextCompat.getColor(context, R.color.accentColor); break; case Warning: color = Color.parseColor("#D4FFA300"); break; } imgView.setColorFilter(color); }
From source file:com.example.android.recyclingbanks.MainActivity.java
/** * Toggle the button colour// w ww .j a va 2 s .c o m * @param buttonId * @param buttonColor new colour for the button */ private void setButtonColor(int buttonId, int buttonColor) { ImageView ivVectorImage = (ImageView) findViewById(buttonId); ivVectorImage.setColorFilter(getResources().getColor(buttonColor)); }
From source file:me.calebjones.spacelaunchnow.utils.Utils.java
public static void setCategoryIcon(ImageView imageView, String type, Boolean night) { if (type != null) { switch (type) { case "Earth Science": imageView.setImageResource(R.drawable.ic_earth); break; case "Planetary Science": imageView.setImageResource(R.drawable.ic_planetary); break; case "Astrophysics": imageView.setImageResource(R.drawable.ic_astrophysics); break; case "Heliophysics": imageView.setImageResource(R.drawable.ic_heliophysics_alt); break; case "Human Exploration": imageView.setImageResource(R.drawable.ic_human_explore); break; case "Robotic Exploration": imageView.setImageResource(R.drawable.ic_robotic_explore); break; case "Government/Top Secret": imageView.setImageResource(R.drawable.ic_top_secret); break; case "Tourism": imageView.setImageResource(R.drawable.ic_tourism); break; case "Unknown": imageView.setImageResource(R.drawable.ic_unknown); break; case "Communications": imageView.setImageResource(R.drawable.ic_satellite); break; case "Resupply": imageView.setImageResource(R.drawable.ic_resupply); break; default://from w w w . j a va 2s.com imageView.setImageResource(R.drawable.ic_unknown); break; } } else { imageView.setImageResource(R.drawable.ic_unknown); } if (night) { imageView.setColorFilter(Color.WHITE); } else { imageView.setColorFilter(Color.BLACK); } }
From source file:com.google.samples.apps.iosched.navigation.AppNavigationViewAsDrawerImpl.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that shows * which account the user is logged in as, and lets them switch accounts. It also shows the * user's Google+ cover photo as background. *//*from w w w .j a va 2 s.com*/ private void setupAccountBox() { final View chosenAccountView = mActivity.findViewById(R.id.chosen_account_view); if (chosenAccountView == null) { //This activity does not have an account box return; } Account chosenAccount = AccountUtils.getActiveAccount(mActivity); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); } ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); String imageUrl = AccountUtils.getPlusImageUrl(mActivity); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(mActivity); if (coverImageUrl != null) { mActivity.findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.GONE); coverImageView.setVisibility(View.VISIBLE); coverImageView.setContentDescription( mActivity.getResources().getString(R.string.navview_header_user_image_content_description)); mImageLoader.loadImage(coverImageUrl, coverImageView); coverImageView.setColorFilter(mActivity.getResources().getColor(R.color.light_content_scrim)); } else { mActivity.findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.VISIBLE); coverImageView.setVisibility(View.GONE); } List<Account> accounts = Arrays.asList(AccountUtils.getActiveAccount(getContext())); populateAccountList(accounts); }
From source file:com.thingsee.tracker.MainActivity.java
@SuppressLint("InflateParams") private Marker makeMarkerToMap(LatLng latLng, boolean visible, boolean alarmActive, String name, double timeStamp, double accuracy) { String snippet;//w ww. j ava2s.c o m LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout tv = (LinearLayout) inflater.inflate(R.layout.tracker_map_marker, null, false); TextView trackerName = (TextView) tv.findViewById(R.id.tracker_name); trackerName.setText(name); ImageView image2 = (ImageView) tv.findViewById(R.id.tracker_marker_icon); if (alarmActive) { image2.setColorFilter(mResources.getColor(R.color.red)); trackerName.setTextColor(mResources.getColor(R.color.white_effect)); } else { image2.setColorFilter(mResources.getColor(R.color.dark_blue)); trackerName.setTextColor(mResources.getColor(R.color.white_effect)); } tv.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight()); tv.setDrawingCacheEnabled(true); tv.buildDrawingCache(); Bitmap bm = tv.getDrawingCache(); tv = null; if (accuracy != -1) { snippet = String.format(mResources.getString(R.string.tracker_accuracy), accuracy); } else { snippet = String.format(mResources.getString(R.string.tracker_accuracy), 0.0f); } if (timeStamp != 0) { String timeStampText = Utilities.getSmartTimeStampString(mContext, mResources, timeStamp); snippet = snippet + "\n" + mResources.getString(R.string.tracker_timestamp) + " " + timeStampText; } else { snippet = snippet + "\n" + mResources.getString(R.string.tracker_timestamp) + " - "; } return mMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(bm)) .visible(visible).title(name).snippet(snippet)); }
From source file:org.onebusaway.android.ui.NavigationDrawerFragment.java
private void formatNavDrawerItem(View view, int itemId, boolean selected) { if (isSeparator(itemId)) { // Don't do any formatting return;//from ww w . j a v a 2 s.c o m } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); /** * Configure its appearance according to whether or not it's selected. Certain items * (e.g., Settings) don't get formatted upon selection, since they open a new activity. */ if (selected) { if (isNewActivityItem(itemId)) { // Don't change any formatting, since this is a category that launches a new activity return; } else { // Show the category as highlighted by changing background, text, and icon color view.setSelected(true); titleView.setTextColor(getResources().getColor(R.color.navdrawer_text_color_selected)); iconView.setColorFilter(getResources().getColor(R.color.navdrawer_icon_tint_selected)); } } else { // Show the category as not highlighted, if its not currently selected if (itemId != mCurrentSelectedPosition) { view.setSelected(false); titleView.setTextColor(getResources().getColor(R.color.navdrawer_text_color)); iconView.setColorFilter(getResources().getColor(R.color.navdrawer_icon_tint)); } } }