设置活动标题正面颜色更改 [英] SettingsActivity Title Front Color change
问题描述
我在带有Android Studio的Android的Guild App上写东西.
I write on a Guild App for Android with Android Studio.
这是我的问题,
在我的 MainActivity 中,是标题颜色和菜单打开器黑色:
And here is my problem,
In my MainActivity is the title color and menu opener black:
在我的 SettingsActivity 中,来自Android Studio的模板是标题颜色和箭头白色:
And in my SettingsActivity is the template from Android Studio is the title color And arrow white:
在哪里可以编辑总是具有相同颜色的内容?
Where can I edit what both have always the same colors?
编辑1
@Sodiq这是我的代码:
Edit 1
@Sodiq
here is my Code:
这里是我的 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>
这是我的 SettingsActivity 页面中的代码:
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);
}
}
这是我的 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>
我的 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>
,这在我的清单中:
<activity
android:name=".settings.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar"></activity>
编辑2
通过从操作栏
通过 Sodiq 的简单方法为我提供了帮助彩色的状态栏
have help me this for easy way from Sodiq for a colored Statusbar
来自Sodiq的代码
更改清单条目
android:theme="@style/AppTheme.NoActionBar"
收件人
android:theme="@style/AppTheme"
并更改 Style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
到
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
感谢 Sodiq 为您提供帮助
推荐答案
尝试删除活动中的 android:theme ="@ style/AppTheme.NoActionBar",仅使用
android:theme ="@ style/AppTheme在清单上的应用程序上
Try to remove android:theme="@style/AppTheme.NoActionBar" on your activity and only use
android:theme="@style/AppTheme"` on your application on manifest
并将主题样式<样式名称="AppTheme" parent ="Theme.AppCompat.Light.DarkActionBar">
更改为<样式名称="AppTheme" parent ="Theme.AppCompat.Light.NoActionBar">
这篇关于设置活动标题正面颜色更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!