gpt4 book ai didi

java - 更改窗口标题背景样式

转载 作者:行者123 更新时间:2023-12-02 00:07:41 24 4
gpt4 key购买 nike

windowTitleBackgroundStyle 不起作用

我试图将应用程序的窗口标题背景设置为渐变,但它不会产生影响。所以,请帮我解决这个问题。

styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomMenuTitle</item>
</style>

<style name="CustomMenuTitle">
<item name="android:textSize">40dip</item>
<item name="android:background">@drawable/gradient</item>
</style>

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.davud.codeit">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".CodeItActivity"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

</application>

最佳答案

使用此样式

<style name="AppTheme" parent="@android:style/Theme">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomMenuTitle</item>
<item name="android:windowTitleStyle">@style/CustomTitleStyle</item>
<item name="android:windowTitleSize">60dp</item>
</style>


<style name="CustomMenuTitle">
<item name="android:background">@drawable/gradient</item>
</style>

<style name="CustomTitleStyle">
<item name="android:textSize">40dp</item>
<item name="android:textColor">@color/colorblue</item>
</style>

并用 Activity 扩展 YourActivity

public class YourActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_name);
}
}

关于java - 更改窗口标题背景样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58144880/

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