Jesse Lukas Jesse Lukas - 1 month ago 18
Android Question

SettingsActivity Title Front Color change

I write on a Guild App for Android with Android Studio.

And here is my problem,

In my MainActivity is the title color and menu opener black:

MainActivity

And in my SettingsActivity is the template from Android Studio is the title color And arrow white:

SettingsActivity

Where can I edit what both have always the same colors?

Edit 1

@Sodiq
here is my Code:

here my settings_toolbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
</android.support.design.widget.AppBarLayout>


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.CoordinatorLayout>


Here my the code in My SettingsActivity page:

private void setupActionBar() {
ViewGroup rootView = (ViewGroup)findViewById(R.id.action_bar_root); //id from appcompat

if (rootView != null) {
View view = getLayoutInflater().inflate(R.layout.app_bar_settings1, rootView, false);
rootView.addView(view, 0);

Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
int color_one = settings.getInt("color_one", 0);

toolbar.setBackgroundColor(color_one);
}

ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
}
}


This is my color.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#ff0000</color>
<color name="colorPrimaryDark">#363636</color>
<color name="colorAccent">#FF4081</color>
<color name="white">#FFFFFF</color>
</resources>


My style.xml:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here.-->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="titleTextColor">@android:color/black</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>


and this in my Manifest:

<activity
android:name=".settings.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar"></activity>

Answer

Try to remove android:theme="@style/AppTheme.NoActionBar" on your activity and only useandroid:theme="@style/AppTheme"` on your application on manifest

And changes your theme style <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> to <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">