mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() { @Override public void onStateChanged(AppBarLayout appBarLayout, State state) { Toolbar toolbar = (Toolbar) mAppBarLayout.findViewById(R.id.toolbar_top); int toolbarBackground = (state == AppBarStateChangeListener.State.COLLAPSED) ? R.color.color_collapsed : R.color.color_non_collapsed; toolbar.setBackgroundColor(ContextCompat.getColor(DealsOptionsActivity.this, toolbarBackground)); } });
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setBackgroundColor(Color.CYAN); }
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setBackgroundColor(Color.BLACK);
toolbar.inflateMenu(R.menu.menu_settings); toolbar.setNavigationIcon(null); toolbar.setBackgroundColor(getResources().getColor(R.color.red)); } else { toolbar.setTitle("Toolbar Test 1"); toolbar.inflateMenu(R.menu.menu_testing_action_bar); toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.nav_tint)); toolbar.setBackgroundColor(getResources().getColor(R.color.primary));
public class FragmentOne extends Fragment { Toolbar toolbar; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); } @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser) { toolbar.setBackgroundColor(ContextCompat.getColor(getApplicationContext(),R.color.classColor2)); } } }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ View v = inflater.inflate(R.layout.fragment_map, container, false); Toolbar toolbar = (Toolbar) v.findViewById(R.id.actionBar); toolbar.setBackgroundColor(Color.parseColor("#212121")); //---- changes --- ((MapActivity) getActivity()).setTitle(Html.fromHtml("<font color='#FFFFFF'>" + getResources().getString(R.string.map) + "</font>")); ((MapActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); ((MapActivity) getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(false); return v; }
private void setBackgroundColor(Color c) { Toolbar.setBackgroundColor(c); if (Recorder.record) Recorder.record("setBackgroundColor", c.getRed(), c.getGreen(), c.getBlue()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.feedback_activity); Toolbar tb = (Toolbar) findViewById(R.id.fb_toolbar); setSupportActionBar(tb); //Parse a color with any hex code tb.setBackgroundColor(Color.parseColor("#FFFFFF")); //Set title tb.setTitle("Your title"); }
private void setBackgroundColor(Color c) { Toolbar.setBackgroundColor(c); if (Recorder.record) Recorder.record("setBackgroundColor", c.getRed(), c.getGreen(), c.getBlue()); }
ab.setCustomView(R.layout.actionbar_main); Toolbar parent =(Toolbar) ab.getCustomView().getParent(); parent.setContentInsetsAbsolute(0,0); parent.setBackgroundColor(Color.parseColor("#00A0D1"));
Toolbar toolbar; // your toolbar toolbar.setBackgroundColor(newColor); // i don't tested this method. Write if it's not working toolbar.setTitleTextColor(titleColor); // if toolbar is white set title to black, if toolbar is black set title to white
static void setColor(int red, int green, int blue, boolean foreground) { if (red<0) red=0; if (green<0) green=0; if (blue<0) blue=0; if (red>255) red=255; if (green>255) green=255; if (blue>255) blue=255; Color c = new Color(red, green, blue); if (foreground) { Toolbar.setForegroundColor(c); ImagePlus img = WindowManager.getCurrentImage(); if (img!=null) img.getProcessor().setColor(c); } else Toolbar.setBackgroundColor(c); }
static void setColor(int red, int green, int blue, boolean foreground) { if (red<0) red=0; if (green<0) green=0; if (blue<0) blue=0; if (red>255) red=255; if (green>255) green=255; if (blue>255) blue=255; Color c = new Color(red, green, blue); if (foreground) { Toolbar.setForegroundColor(c); ImagePlus img = WindowManager.getCurrentImage(); if (img!=null) img.getProcessor().setColor(c); } else Toolbar.setBackgroundColor(c); }
void setDrawingColor(int x, int y, boolean setBackground) { int p = ip.getPixel(x, y); int r = (p&0xff0000)>>16; int g = (p&0xff00)>>8; int b = p&0xff; Color c = new Color(r, g, b); if (setBackground) { Toolbar.setBackgroundColor(c); if (Recorder.record) Recorder.setBackgroundColor(c); } else { Toolbar.setForegroundColor(c); if (Recorder.record) Recorder.setForegroundColor(c); } }
void setDrawingColor(int x, int y, boolean setBackground) { int p = ip.getPixel(x, y); int r = (p&0xff0000)>>16; int g = (p&0xff00)>>8; int b = p&0xff; Color c = new Color(r, g, b); if (setBackground) { Toolbar.setBackgroundColor(c); if (Recorder.record) Recorder.setBackgroundColor(c); } else { Toolbar.setForegroundColor(c); if (Recorder.record) Recorder.setForegroundColor(c); } }
void editColor() { Color c = background?Toolbar.getBackgroundColor():Toolbar.getForegroundColor(); ColorChooser cc = new ColorChooser((background?"Background":"Foreground")+" Color", c, false); c = cc.getColor(); if (background) Toolbar.setBackgroundColor(c); else Toolbar.setForegroundColor(c); }
void editColor() { Color c = background?Toolbar.getBackgroundColor():Toolbar.getForegroundColor(); ColorChooser cc = new ColorChooser((background?"Background":"Foreground")+" Color", c, false); c = cc.getColor(); if (background) Toolbar.setBackgroundColor(c); else Toolbar.setForegroundColor(c); }
public void colorOptions(ColorRGB fgColor, ColorRGB bgColor) { Toolbar.setForegroundColor(AWTColors.getColor(fgColor)); Toolbar.setBackgroundColor(AWTColors.getColor(bgColor)); OptionsChannels options = optionsService.getOptions(OptionsChannels.class); options.setLastFgColor(fgColor, false); options.setLastBgColor(bgColor, false); //options.save(); BDZ - shouldn't be necessary - see OptionsChannels impl }
public void itemStateChanged(ItemEvent e) { Choice choice = (Choice)e.getSource(); String item = choice.getSelectedItem(); Color color = getColor(item, Color.black); if (choice==fchoice) Toolbar.setForegroundColor(color); else if (choice==bchoice) Toolbar.setBackgroundColor(color); else if (choice==schoice) { Roi.setColor(color); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null && imp.getRoi()!=null) imp.draw(); Toolbar.getInstance().repaint(); } }
public void itemStateChanged(ItemEvent e) { Choice choice = (Choice)e.getSource(); String item = choice.getSelectedItem(); Color color = getColor(item, Color.black); if (choice==fchoice) Toolbar.setForegroundColor(color); else if (choice==bchoice) Toolbar.setBackgroundColor(color); else if (choice==schoice) { Roi.setColor(color); ImagePlus imp = WindowManager.getCurrentImage(); if (imp!=null && imp.getRoi()!=null) imp.draw(); Toolbar.getInstance().repaint(); } }