gpt4 book ai didi

android - 更改 Activity 中的背景颜色。

转载 作者:太空狗 更新时间:2023-10-29 15:40:35 24 4
gpt4 key购买 nike

我使用 Android Studio 通过新建 -> Activity -> 基本 Activity 创建基本 Activity 。但是 Activity 背景颜色是黑色。我知道这是为了减少电池消耗。但是有没有办法在不改变样式的情况下将其更改为白色。

我尝试更改根布局的背景颜色,但它不会显示编辑文本字段的提示文本。因为它的颜色是白色的。

然后我尝试将主题从 Material 更改为 Material Lite,然后当我在设备中运行应用程序时它不会显示更改。

enter image description here

这里是AndroidManifest.xml中的activity声明

<activity
android:name=".SearchBus"
android:label="@string/title_activity_search_bus"
android:parentActivityName=".MapsActivity"
>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="uk.co.stableweb.iroute.MapsActivity" />
</activity>

最佳答案

在您的 styles.xml 中,为您用于应用程序或 Activity 的任何主题设置 android:windowBackground 属性。您可以在 AndroidManifest.xml 中找到您正在使用的主题。

<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowBackground">@color/somecolor</item>
</style>

</resources>

注意:如果您的布局中有不透明的 View ,它会阻止您看到您在此处设置的颜色。

关于android - 更改 Activity 中的背景颜色。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39112632/

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