简体   繁体   中英

Action Bar Title Text Color

I am having an Activity that extends the AppCompatActivity. I am using the theme Theme.AppCompat.Light.DarkActionBar . Now, the text color of the TitleText in the ActionBar shows up black. I want to set this color to white.

How can this be possibly achieved ? Do I change the theme to something else (if yes then what) or can I change the color by making changes through the ThemeEditor available in the latest version of the Android Studio or can something be done with the getSupportActionBar() programmatically ?

I personally chose the programmatical way.

In your code, you can assign a custom layout to your ActionBar .

Like this:

android.support.v7.app.ActionBar mActionBar = getSupportActionBar();
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setDisplayUseLogoEnabled(false);
mActionBar.setDisplayHomeAsUpEnabled(false);
mActionBar.setDisplayShowCustomEnabled(true);
mActionBar.setDisplayShowHomeEnabled(false);


ViewGroup actionBarLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.topbarclassic,null);
mActionBar.setCustomView(actionBarLayout);

Then just change the text color of your textview containing the text inside the ActionBar as following:

        android:textColor="#FFFFFF"

You can simply change the action bar tittle color using this code You add below code to your Oncreate method

setTitleColor(YOUR COLOR);

Hope this helps.

尝试在您的Activity这样做

getActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#DCDCDC"))); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM