Java Code Examples for androidx.appcompat.widget.Toolbar#setTitleTextColor()
The following examples show how to use
androidx.appcompat.widget.Toolbar#setTitleTextColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavigationViewActivity.java From android-test with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.navigation_view_activity); // Set up the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(toolbar); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Set up the navigation drawer. mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackground(R.color.theme_primary); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); if (navigationView != null) { setupDrawerContent(navigationView); } selectedNavItemTextView = (TextView) findViewById(R.id.selected_nav_item_text_view); }
Example 2
Source File: UCropActivity.java From EasyPhotos with Apache License 2.0 | 6 votes |
/** * Configures and styles both status bar and toolbar. */ private void setupAppBar() { setStatusBarColor(mStatusBarColor); final Toolbar toolbar = findViewById(R.id.toolbar); // Set all of the Toolbar coloring toolbar.setBackgroundColor(mToolbarColor); toolbar.setTitleTextColor(mToolbarWidgetColor); final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(mToolbarWidgetColor); toolbarTitle.setText(mToolbarTitle); // Color buttons inside the Toolbar Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate(); stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(stateButtonDrawable); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); } }
Example 3
Source File: RuntimePermissionsActivity.java From android-test with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_runtime_permissions); // Set up the toolbar. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mPhoneStatePermissionStatus = (TextView) findViewById( R.id.phone_state_permission_permission_status); mGetAccountsPermissionStatus = (TextView) findViewById(R.id.get_accounts_permission_status); }
Example 4
Source File: DConnectSettingCompatPageFragmentActivity.java From DeviceConnect-Android with MIT License | 6 votes |
/** * ViewPagerを持つレイアウトを自動的に設定する. * サブクラスでオーバーライドする場合は setContentView を<strong>実行しないこと</strong>。 * * @param savedInstanceState パラメータ * @see android.app.Activity#onCreate(Bundle) */ @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting_page); mViewPager = (ViewPager) findViewById(R.id.setting_pager); mViewPager.setAdapter(new DConnectFragmentPagerAdapter(getSupportFragmentManager(), this)); Toolbar toolbar = new Toolbar(this); toolbar.setTitle(org.deviceconnect.android.deviceplugin.chromecast.R.string.activity_setting_page_title); toolbar.setBackgroundColor(Color.parseColor("#00a0e9")); toolbar.setTitleTextColor(Color.parseColor("#FFFFFF")); addContentView(toolbar, new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); toolbar.setNavigationIcon(org.deviceconnect.android.deviceplugin.chromecast.R.drawable.close_icon); toolbar.setNavigationOnClickListener((view) -> { finish(); }); setSupportActionBar(toolbar); }
Example 5
Source File: MainActivity.java From YouTube-In-Background with MIT License | 6 votes |
/** * Save app theme color in preferences */ private void setColors(int backgroundColor, int textColor) { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setBackgroundColor(backgroundColor); toolbar.setTitleTextColor(textColor); TabLayout tabs = (TabLayout) findViewById(R.id.tabs); tabs.setBackgroundColor(backgroundColor); tabs.setTabTextColors(textColor, textColor); SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(this); sp.edit().putInt("BACKGROUND_COLOR", backgroundColor).apply(); sp.edit().putInt("TEXT_COLOR", textColor).apply(); initialColors[0] = backgroundColor; initialColors[1] = textColor; }
Example 6
Source File: UCropActivity.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * Configures and styles both status bar and toolbar. */ private void setupAppBar() { setStatusBarColor(mStatusBarColor); final Toolbar toolbar = findViewById(R.id.toolbar); // Set all of the Toolbar coloring toolbar.setBackgroundColor(mToolbarColor); toolbar.setTitleTextColor(mToolbarWidgetColor); final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(mToolbarWidgetColor); toolbarTitle.setText(mToolbarTitle); // Color buttons inside the Toolbar Drawable stateButtonDrawable = AppCompatResources.getDrawable(this, mToolbarCancelDrawable).mutate(); stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(stateButtonDrawable); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); } }
Example 7
Source File: SystemUIUtils.java From Deadline with GNU General Public License v3.0 | 6 votes |
public static void setupActionBar(Activity activity, boolean isLightBar, int bgColorRes, int bgColorRes2, int titleRes, Toolbar toolbar) { Window window = activity.getWindow(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { window.setStatusBarColor(activity.getResources().getColor(bgColorRes2)); if (!isLightBar) { toolbar.setTitleTextColor(activity.getResources().getColor(R.color.white)); } } else { window.setStatusBarColor(activity.getResources().getColor(bgColorRes, null)); if (isLightBar) { window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } else { toolbar.setTitleTextColor(activity.getResources().getColor(R.color.white)); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } } toolbar.setTitle(activity.getString(titleRes)); ((AppCompatActivity) activity).setSupportActionBar(toolbar); ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(true); } }
Example 8
Source File: PictureMultiCuttingActivity.java From Matisse-Kotlin with Apache License 2.0 | 6 votes |
/** * Configures and styles both status bar and toolbar. */ private void setupAppBar() { setStatusBarColor(mStatusBarColor); final Toolbar toolbar = findViewById(R.id.toolbar); // Set all of the Toolbar coloring toolbar.setBackgroundColor(mToolbarColor); toolbar.setTitleTextColor(mToolbarWidgetColor); final TextView toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbarTitle.setTextColor(mToolbarWidgetColor); toolbarTitle.setText(mToolbarTitle); // Color buttons inside the Toolbar Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate(); stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP); toolbar.setNavigationIcon(stateButtonDrawable); setSupportActionBar(toolbar); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowTitleEnabled(false); } }
Example 9
Source File: ThemePreviewActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { appBarLayout.setBackgroundColor(customTheme.colorPrimary); toolbar.setTitleTextColor(customTheme.toolbarPrimaryTextAndIconColor); toolbar.setSubtitleTextColor(customTheme.toolbarSecondaryTextColor); if (toolbar.getNavigationIcon() != null) { toolbar.getNavigationIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN); } if (toolbar.getOverflowIcon() != null) { toolbar.getOverflowIcon().setColorFilter(customTheme.toolbarPrimaryTextAndIconColor, android.graphics.PorterDuff.Mode.SRC_IN); } }
Example 10
Source File: SettingsActivity.java From Rucky with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); final SharedPreferences settings = getSharedPreferences(PREF_SETTINGS, MODE_PRIVATE); darkTheme = settings.getBoolean(PREF_SETTINGS_DARK_THEME,true); launchIcon = settings.getBoolean(PREF_SETTINGS_LAUNCH_ICON,false); advSecurity = settings.getBoolean(PREF_SETTING_ADV_SECURITY, false); setTheme(darkTheme?R.style.AppThemeDark:R.style.AppThemeLight); setContentView(R.layout.activity_settings); Toolbar toolbar = findViewById(R.id.toolbarSettings); setSupportActionBar(toolbar); getSupportFragmentManager().beginTransaction().replace(R.id.setting_container, new RootSettingsFragment()).commit(); toolbar.setTitleTextColor(ContextCompat.getColor(this,R.color.accent)); }
Example 11
Source File: ContactsActivity.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { YcShareElement.enableContentTransition(getApplication()); YcShareElement.setExitTransition(this,new Slide(Gravity.LEFT)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_contact); Toolbar toolbar = findViewById(R.id.tool_bar); toolbar.setTitle("Contacts"); toolbar.setTitleTextColor(0xDDFFFFFF); initRecyclerView(); }
Example 12
Source File: BaseActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
protected void applyAppBarLayoutAndToolbarTheme(AppBarLayout appBarLayout, Toolbar toolbar) { appBarLayout.setBackgroundColor(customThemeWrapper.getColorPrimary()); toolbar.setTitleTextColor(customThemeWrapper.getToolbarPrimaryTextAndIconColor()); toolbar.setSubtitleTextColor(customThemeWrapper.getToolbarSecondaryTextColor()); if (toolbar.getNavigationIcon() != null) { toolbar.getNavigationIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); } if (toolbar.getOverflowIcon() != null) { toolbar.getOverflowIcon().setColorFilter(customThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); } }
Example 13
Source File: MainActivity.java From WebviewProject with MIT License | 5 votes |
void addToolbar(){ Toolbar toolbar=findViewById(R.id.main_toolbar); setSupportActionBar(toolbar); toolbar.setTitleTextColor(getResources().getColor(R.color.backgroundWhite));//TODO Title color of toolbar toolbar.setLogo(R.mipmap.ic_launcher);//TODO Logo of toolbar toolbar.setElevation(2);//TODO Shadow under the toolbar }
Example 14
Source File: scanner_activity.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.scanner_activity); Toolbar toolbar = findViewById(R.id.scan_toolbar); toolbar.setTitle(R.string.scan_title); toolbar.setTitleTextColor(Color.WHITE); ViewGroup contentFrame = findViewById(R.id.content_frame); scanner_view = new ZXingScannerView(this); contentFrame.addView(scanner_view); }
Example 15
Source File: TabSettingActivity.java From mhzs with MIT License | 5 votes |
@Override protected void initToolbar(Toolbar mToolbar) { mToolbar.setTitle("底部栏设置"); mToolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Example 16
Source File: AdSettingActivity.java From mhzs with MIT License | 5 votes |
@Override protected void initToolbar(Toolbar mToolbar) { mToolbar.setTitle("广告净化"); mToolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Example 17
Source File: MainActivity.java From mhzs with MIT License | 5 votes |
@Override protected void initToolbar(Toolbar mToolbar) { mToolbar.setTitle("麻花影视助手"); mToolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(false); }
Example 18
Source File: ExpSettingActivity.java From mhzs with MIT License | 5 votes |
@Override protected void initToolbar(Toolbar mToolbar) { mToolbar.setTitle("实验性功能"); mToolbar.setTitleTextColor(Color.WHITE); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Example 19
Source File: Utility.java From Instagram-Profile-Downloader with MIT License | 5 votes |
public static void setToolbar(AppCompatActivity activity, Toolbar toolbar, String title) { toolbar.setTitle(title); toolbar.setTitleTextColor(activity.getResources().getColor(R.color.white)); activity.setSupportActionBar(toolbar); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Objects.requireNonNull(activity.getSupportActionBar()).setDisplayHomeAsUpEnabled(true); } }
Example 20
Source File: ToolbarColorizeHelper.java From arcusandroid with Apache License 2.0 | 4 votes |
/** * Use this method to colorize toolbar icons to the desired target color * * @param toolbarView toolbar view being colored * @param toolbarIconsColor the target color of toolbar icons * @param activity reference to activity needed to register observers */ public static void colorizeToolbar(@NonNull Toolbar toolbarView, int toolbarIconsColor, @NonNull Activity activity) { final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, PorterDuff.Mode.MULTIPLY); for (int i = 0; i < toolbarView.getChildCount(); i++) { final View v = toolbarView.getChildAt(i); //Step 1 : Changing the color of back button (or open drawer button). if (v instanceof ImageButton) { //Action Bar back button ((ImageButton) v).getDrawable().setColorFilter(colorFilter); } if (v instanceof ActionMenuView) { for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) { //Step 2: Changing the color of any ActionMenuViews - icons that are not back button, nor text, nor overflow menu icon. //Colorize the ActionViews -> all icons that are NOT: back button | overflow menu final View innerView = ((ActionMenuView) v).getChildAt(j); if (innerView instanceof ActionMenuItemView) { for (int k = 0; k < ((ActionMenuItemView) innerView).getCompoundDrawables().length; k++) { if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) { final int finalK = k; //Important to set the color filter in seperate thread, by adding it to the message queue //Won't work otherwise. innerView.post(new Runnable() { @Override public void run() { Drawable drawable = ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK]; if (drawable != null) { drawable.setColorFilter(colorFilter); } } }); } } } } } //Step 3: Changing the color of title and subtitle. toolbarView.setTitleTextColor(toolbarIconsColor); toolbarView.setSubtitleTextColor(toolbarIconsColor); } }