gpt4 book ai didi

android - 导航到下一个 Activity 时更改操作栏颜色及其文本对齐方式

转载 作者:行者123 更新时间:2023-11-30 01:02:35 25 4
gpt4 key购买 nike

我想在我的 Android 应用程序中更改 ActionBar 的颜色。

如果我点击按钮转到下一个 Activity ,我也想更改 Actionbar 颜色,但它显示“不幸的是,应用程序已停止”。

下面是我的代码,如果有什么问题请告诉我......?

我的代码:

list 代码:

<application
android:allowBackup="true"
android:icon="@drawable/app_icon_152"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.Light">
<activity
android:name=".WelcomeScreen"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SignIn"
android:label="Sign In"
android:theme="@style/MyTheme"
android:parentActivityName=".WelcomeScreen"></activity>
</application>

values/theme.xml代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/TitleBarTextColor</item>
<item name="android:background">#3366CC</item>
<item name="android:icon">@drawable/backarrow_white</item>
</style>
<style name="TitleBarTextColor" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
</resources>

values/styles.xml代码:

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowActionBar">true</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@drawable/splashscreen</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
</style>
</resources>

任何帮助将不胜感激。提前致谢。

最佳答案

试试这个

<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>

<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
</style>

关于android - 导航到下一个 Activity 时更改操作栏颜色及其文本对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39242224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com