Android找到默认背景颜色

Android找到默认背景颜色,第1张

概述我有一个简单的回收查看应用程序. 布局声明如下 <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_hei 我有一个简单的回收查看应用程序.

布局声明如下

<?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中,设计视图中的背景颜色为空白.

所以我的问题是,这种灰色的颜色来自哪里?如何将其普遍改为白色?

我显然可以添加背景:白色到这个特定的视图.但有没有办法覆盖系统默认值?

解决方法 您所看到的实际上是活动的背景,而不是RecyclervIEw,默认情况下它是透明的.颜色确实改变了每个AndroID版本的查看时间.

You can overrIDe this in your app theme.

First define the color in values/colors.xml

<resources>     <color name="background">#FF0000 </color>  </resources>

Create a themes.xml file in res/values that references that color:

<resources>      <style name="Mytheme" parent="@androID:style/theme.light">               <item name="androID:windowBackground">@color/background</item>      </style> </resources>

and then in your AndroIDManifest.xml specify this as
the theme for your activitIEs to use.

<activity        androID:name=".MyActivity"        androID:theme="@style/Mytheme" />

见https://stackoverflow.com/a/10157077/4623782

总结

以上是内存溢出为你收集整理的Android找到默认背景颜色全部内容,希望文章能够帮你解决Android找到默认背景颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1123195.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存