Java Code Examples for android.support.v7.widget.Toolbar#setTitleTextColor()

The following examples show how to use android.support.v7.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: SettingsActivity.java    From AppUpdater with Apache License 2.0 6 votes vote down vote up
@Override
public void setContentView(int layoutResID) {
    ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.activity_settings, new LinearLayout(this), false);
    Toolbar toolbar = (Toolbar) contentView.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.action_settings);
    toolbar.setTitleTextColor(ContextCompat.getColor(this, android.R.color.white));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });

    ViewGroup contentWrapper = (ViewGroup) contentView.findViewById(R.id.content_wrapper);
    LayoutInflater.from(this).inflate(layoutResID, contentWrapper, true);
    getWindow().setContentView(contentView);

}
 
Example 2
Source File: NoteEditActvity.java    From multi-copy with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_note_edit_actvity);
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setTitle("Notes");
    toolbar.setTitleTextColor(Color.WHITE);
    Intent i = getIntent();
    String thisNote = i.getStringExtra(Constants.NOTES_EDIT_TEXT);
    position = i.getIntExtra(Constants.NOTES_EDIT_POSITION,0);

    etNotesDetail = (EditText) findViewById(R.id.etNoteEdit);
    if(notesEdit_LOG)
    Log.d(TAG, "onCreate: " + thisNote);
    etNotesDetail.setText(thisNote);
    if(thisNote != null)
    etNotesDetail.setSelection(thisNote.length());
}
 
Example 3
Source File: MainActivity.java    From MaterialTextField with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Fabric.with(this, new Crashlytics());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitleTextColor(Color.WHITE);

    final ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 4
Source File: CreditHistoryActivity.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_credit_history);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Credit History");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));

    allList = new ArrayList<>();

    adapter = new PhotosAdapter(context, allList);
    adapter.setClickListener(new PhotosAdapter.ClickListener() {
        @Override
        public void onItemClickListener(View v, int pos) {
            //gotoDetailsActivity();
        }
    });

    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
    recyclerView.setAdapter(adapter);

}
 
Example 5
Source File: SettingsActivity.java    From MLManager with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setContentView(int layoutResID) {
    ViewGroup contentView = (ViewGroup) LayoutInflater.from(this).inflate(R.layout.activity_settings, new LinearLayout(this), false);
    toolbar = (Toolbar) contentView.findViewById(R.id.toolbar);
    //TODO Toolbar should load the default style in XML (white title and back arrow), but doesn't happen
    toolbar.setTitleTextColor(getResources().getColor(R.color.white));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });

    ViewGroup contentWrapper = (ViewGroup) contentView.findViewById(R.id.content_wrapper);
    LayoutInflater.from(this).inflate(layoutResID, contentWrapper, true);
    getWindow().setContentView(contentView);

}
 
Example 6
Source File: LeaderBoardActivity.java    From Nimbus with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_leaderboard);

    progressBar = (ProgressBar) findViewById(R.id.leader_progress);
    recyclerView = (RecyclerView) findViewById(R.id.leader_recycler);
    toolbar = (Toolbar) findViewById(R.id.leader_toolbar);

    toolbar.setTitle("LeaderBoard");
    toolbar.setTitleTextColor(Color.WHITE);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    progressBar.setVisibility(View.VISIBLE);

    layoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    getLeaderBoard();

}
 
Example 7
Source File: FriendFacebookActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_friends_search);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Find friends on Facebook");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));

    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);


    allList = new ArrayList<>();
    allAdapter = new FriendAdapter(context, allList);
    /*
    allAdapter.setClickListener(new FriendAdapter.ClickListener() {
        @Override
        public void onItemClickListener(View v, int pos) {

        }

        @Override
        public void onFriendListener(int pos, boolean isFollowing) {

        }
    });*/

    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setAdapter(allAdapter);

    setList();
}
 
Example 8
Source File: BaseActivity.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 5 votes vote down vote up
public void configToolbar(String title){
    Toolbar toolbar = (Toolbar) findViewById(R.id.tl_custom);
    toolbar.setTitle(title);
    toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.white));
    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
 
Example 9
Source File: CommonActivity.java    From SwipeBack with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_common);
    setTitle("Common");
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    setSupportActionBar(toolbar);
    setDragEdge(SwipeBackLayout.DragEdge.LEFT);
}
 
Example 10
Source File: WebActivity.java    From monolog-android with MIT License 5 votes vote down vote up
private void initUI() {
    //Set up the toolbar
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(mTitle);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    toolbar.setTitleTextColor(Color.BLACK);
    //bind view
    mWebView = (WebView) findViewById(R.id.webview);
}
 
Example 11
Source File: SettingActivity.java    From YourWeather with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    mToolbar.setTitleTextColor(Color.WHITE);
    delegate.getSupportActionBar().setDisplayShowTitleEnabled(false);
    delegate.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

}
 
Example 12
Source File: FriendZomatoActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_friends_search);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Find friends on Zomato");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));

    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);


    allList = new ArrayList<>();
    allAdapter = new FriendAdapter(context, allList);
    /*allAdapter.setClickListener(new FriendAdapter.ClickListener() {
        @Override
        public void onItemClickListener(View v, int pos) {

        }

        @Override
        public void onFriendListener(int pos, boolean isFollowing) {

        }
    });*/

    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.setNestedScrollingEnabled(false);
    recyclerView.setAdapter(allAdapter);

    setList();
}
 
Example 13
Source File: CreditsActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_credits);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Zomato Credits");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));
}
 
Example 14
Source File: MainActivity.java    From Android-UtilCode with Apache License 2.0 5 votes vote down vote up
@Override
public void initView(Bundle savedInstanceState, View view) {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        toolbar.setTitleTextColor(Color.WHITE);
        setSupportActionBar(toolbar);
    }
}
 
Example 15
Source File: StatisticsActivity.java    From Expert-Android-Programming with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_statistics);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Statistics");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));
}
 
Example 16
Source File: MainActivity.java    From android-openslmediaplayer with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // setup event bus
    mAppEventReceiver = new AppEventReceiver(this);
    eventBus().register(mAppEventReceiver);

    // set content view
    setContentView(R.layout.activity_main);

    // set ToolBar as a ActionBar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.app_toolbar_title_text));
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // instantiate NavigationDrawerFragment
    FragmentManager fm = getSupportFragmentManager();

    NavigationDrawerFragment fragment = (NavigationDrawerFragment)
            fm.findFragmentByTag(FRAGMENT_TAG_NAVIGATION_DRAWER);

    if (fragment == null) {
        fragment = (NavigationDrawerFragment)
                Fragment.instantiate(this, NavigationDrawerFragment.class.getName());
        fm.beginTransaction()
                .replace(R.id.drawer_container, fragment, FRAGMENT_TAG_NAVIGATION_DRAWER)
                .commit();
    } else {
        fm.beginTransaction().attach(fragment).commit();
    }

    mNavigationDrawerFragment = fragment;

    // set initial contents
    if (savedInstanceState == null) {
        switchContents(NavigationDrawerReqEvents.SECTION_INDEX_PLAYER_CONTROL);
    }
}
 
Example 17
Source File: ToolbarColorizeHelper.java    From IdeaTrackerPlus with MIT License 4 votes vote down vote up
/**
 * 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(Toolbar toolbarView, int toolbarIconsColor, 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() {
                                    ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                                }
                            });
                        }
                    }
                }
            }
        }

        //Step 3: Changing the color of title and subtitle.
        toolbarView.setTitleTextColor(toolbarIconsColor);
        toolbarView.setSubtitleTextColor(toolbarIconsColor);

        //Step 4: Changing the color of the Overflow Menu icon.
        setOverflowButtonColor(activity, colorFilter);
    }
}
 
Example 18
Source File: ToolbarColorizeHelper.java    From Slide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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(Toolbar toolbarView, int toolbarIconsColor, 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() {
                                    ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                                }
                            });
                        }
                    }
                }
            }
        }

        //Step 3: Changing the color of title and subtitle.
        toolbarView.setTitleTextColor(toolbarIconsColor);
        toolbarView.setSubtitleTextColor(toolbarIconsColor);

        //Step 4: Changing the color of the Overflow Menu icon.
        setOverflowButtonColor(activity, colorFilter);
    }
}
 
Example 19
Source File: SwipeableCard.java    From SwipeableCard with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize Toolbar.
 * @param context Context
 */
@SuppressWarnings("deprecation")
private void initToolbar(Context context, OptionView option)
{
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(titleAttr);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if(colorTitleAttr == 0)
        {
            toolbar.setTitleTextColor(ContextCompat.getColor(context, option.getColorTitle()));
        }
        else {
            toolbar.setTitleTextColor(colorTitleAttr);
        }
        if(colorToolbarAttr == 0)
        {
            toolbar.setBackgroundColor((ContextCompat.getColor(context, option.getColorToolbar())));
        }else {

            toolbar.setBackgroundColor(colorToolbarAttr);
        }

    } else {
        if(colorTitleAttr == 0)
        {
            toolbar.setTitleTextColor(getResources().getColor(option.getColorTitle()));
        }
        else {
            toolbar.setTitleTextColor(colorTitleAttr);
        }
        if(colorToolbarAttr == 0) {
            toolbar.setBackgroundColor(getResources().getColor(option.getColorToolbar()));
        }else{
            toolbar.setBackgroundColor(colorToolbarAttr);
        }
    }
    if (option.isMenuItem()) {
        //Reset menĂ¹ item (avoids duplicate)
        toolbar.getMenu().clear();
        //Set new menĂ¹ item
        toolbar.inflateMenu(option.getMenuItem());
        toolbar.setOnMenuItemClickListener(option.getToolbarListener());
    }
    if(option.isAutoAnimation()) {
        toolbar.setOnClickListener(this);
    }else{
        toolbar.setOnClickListener(null);
    }
}
 
Example 20
Source File: ContributorsActivity.java    From GithubContributorsLib with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    Bundle bundle = getIntent().getExtras();

    String token = null;
    String repositoryUrl = null;

    if (bundle == null || !bundle.containsKey(Contributors.BUNDLE_CONTRIBUTORS_LIBRARY_GITHUB_TOKEN) || !bundle.containsKey(Contributors.BUNDLE_REPOSITORY_URL)) {
        finish();
    }

    //set the theme
    boolean customTheme = false;
    Contributors.ActivityStyle activityStyle = Contributors.ActivityStyle.DARK;

    if (bundle != null) {
        token = bundle.getString(Contributors.BUNDLE_CONTRIBUTORS_LIBRARY_GITHUB_TOKEN);
        repositoryUrl = bundle.getString(Contributors.BUNDLE_REPOSITORY_URL);
        int themeId = bundle.getInt(Contributors.BUNDLE_THEME, -1);
        if (themeId != -1) {
            customTheme = true;
            setTheme(themeId);
        }

        String style = bundle.getString(Contributors.BUNDLE_STYLE);
        if (style != null) {
            activityStyle = Contributors.ActivityStyle.valueOf(style);
        }
    }

    if (!customTheme) {
        if (activityStyle == Contributors.ActivityStyle.DARK) {
            setTheme(R.style.ContributorsLibraryTheme);
        } else if (activityStyle == Contributors.ActivityStyle.LIGHT) {
            setTheme(R.style.ContributorsLibraryTheme_Light);
        } else if (activityStyle == Contributors.ActivityStyle.LIGHT_DARK_TOOLBAR) {
            setTheme(R.style.ContributorsLibraryTheme_Light_DarkToolbar);
        }
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_github_contributors);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    //if we have a darkToolbar set the text white
    if (activityStyle == Contributors.ActivityStyle.LIGHT_DARK_TOOLBAR) {
        toolbar.setTitleTextColor(Color.WHITE);
        toolbar.setSubtitleTextColor(Color.WHITE);
    }
    setSupportActionBar(toolbar);
    //if we use the DarkToolbar style we have to handle the back arrow on our own too
    if (activityStyle == Contributors.ActivityStyle.LIGHT_DARK_TOOLBAR && getSupportActionBar() != null) {
        final Drawable upArrow = getResources().getDrawable(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
        if (upArrow != null) {
            upArrow.setColorFilter(getResources().getColor(android.R.color.white), PorterDuff.Mode.SRC_ATOP);
        }
        getSupportActionBar().setHomeAsUpIndicator(upArrow);
    }

    String title = getString(R.string.contributors_library_name);
    if (bundle != null && bundle.containsKey(Contributors.BUNDLE_TITLE)) {
        title = bundle.getString(Contributors.BUNDLE_TITLE);
    }

    ActionBar ab = getSupportActionBar();
    if (ab != null) {

        // SetUp ActionBar
        ab.setDisplayHomeAsUpEnabled(true);
        if (TextUtils.isEmpty(title)) {
            ab.setDisplayShowTitleEnabled(false);
        } else {
            ab.setDisplayShowTitleEnabled(true);
            ab.setTitle(title);
        }
    }

    ContributorsFragment fragment = ContributorsFragment.newInstance(token, repositoryUrl);

    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
}