gpt4 book ai didi

Android 查找默认背景颜色

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:55:01 32 4
gpt4 key购买 nike

我有一个带有简单 recyclerview 的应用。

布局声明如下

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">


<android.support.v7.widget.RecyclerView
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/some_id" />

</RelativeLayout>

我注意到在不同的设备上,recyclerView 实际上有不同的背景。在较新的设备中,背景只是白色。在旧设备上,背景为浅灰色。

在android studio中,设计 View 中的背景颜色为空白。

所以我的问题是,这种灰色从何而来?如何将其普遍更改为白色?

显然,我可以将 background:white 添加到这个特定的 View 中。但是有没有办法覆盖系统默认值?

最佳答案

安卓默认背景色

 <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground">
</RelativeLayout

使用

 android:background="?android:colorBackground"

关于Android 查找默认背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41000209/

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