Java 设置活动标题前颜色更改
我在安卓工作室的安卓公会应用程序上写作 这就是我的问题,Java 设置活动标题前颜色更改,java,android,android-studio,Java,Android,Android Studio,我在安卓工作室的安卓公会应用程序上写作 这就是我的问题, 在我的main活动中是标题颜色和菜单开场白黑色: 在我的设置中,活动是来自Android Studio的模板是标题颜色和箭头白色: 在哪里可以编辑两种颜色始终相同的内容 编辑1 @索迪克 这是我的密码: 这里是我的设置\u toolbar.xml: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayo
在我的main活动中是标题颜色和菜单开场白黑色: 在我的设置中,活动是来自Android Studio的模板是标题颜色和箭头白色: 在哪里可以编辑两种颜色始终相同的内容 编辑1
@索迪克 这是我的密码: 这里是我的设置\u 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>
<?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>
<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>
这是我的color.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>
<?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>
<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>
到
并更改Style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
到
感谢Sodiq的帮助尝试删除活动中的
android:theme=“@style/AppTheme.NoActionBar”,只在清单上的应用程序中使用android:theme=“@style/AppTheme””
并将您的主题样式
更改为
这对我有帮助了
我在Style.xml中创建了新样式
<style name="AppTheme.Settings" 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>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
@颜色/原色
@颜色/原色暗
@android:彩色/黑色
@颜色/颜色重音
假的
真的
并在我的清单中编辑
<activity
android:name=".settings.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.Settings"></activity>
你可以定制工具栏并在样式文件中设置颜色我尝试添加一个工具栏,他说“此活动有一个actionbar”我对actionbar和工具栏很新,请遵循此链接,例如@JesseLukas是的,你可以在链接上看到,你必须在你的appTheme上使用Theme.AppCompat.Light.NoActionBar
(我之所以分享这个链接,是因为你们对actionbar和toolbar有新的了解&我认为这篇文章可以帮助你们更多地了解toolbar)在你的AndroidManifest.xml中,你的main活动和设置活动的android:theme
值是多少。如果你没有这些标记的android:theme
值,那么标记中的值是多少?另外,在你的styles.xml中,你能为android:theme
中给出的名称发布你的输出吗?我测试了它,现在激活了onbar回来了你解决了吗?如果仍然没有检查我的更新answer@Sodiq我更新得太晚了。很抱歉。你的版本明显比我的版本简单,谢谢你的帮助:-)阅读顶部的编辑主踏板