繁体   English   中英

布局的背景颜色自动更改为白色

[英]Background color of the layout automatically changed to white

我在应用程序的许多地方都使用了这种颜色:#7A96A0。 一切看起来都很好。 但是有时当我更改屏幕或滑动时,布局的背景颜色会自动更改为白色,这在我的整个应用程序中都会发生。 它仅针对这种颜色发生。 此颜色代码有问题。 我已经为Xml文件中的布局提供了背景。 任何人都面临类似的问题。 提前致谢..

颜色代码没有问题, "#7a96a0"是有效的颜色代码。 我认为您应该在strings.xml的color属性中添加值和名称,然后在您的android xml中使用它。

go to res >> values >> strings.xml

然后加

<color name="colour">#7a96a0</color>

在strings.xml中

之后,转到xml文件并添加

<android:background="@color/colour">

无论您要在哪里使用该颜色。

希望这可以帮助

我有一个同样的问题,我的应用程序之一更改了您的背景源并将其链接到这样的形状

shape :shape_sample.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
    <solid android:color="@android:color/white" />
</shape>

并在您的布局 布局中 :my_layout.xml

<TextBox
   android:id="@+id/my_item_textView"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:background="@drawable/shape_sample" />

它对我有用,希望对您有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM