可能的透支:根元素绘制背景

2024-05-18

在我的应用程序中,Android 的 lints 上出现此警告:

可能的过度绘制:根元素使用 @drawable/main 绘制背景 还绘制背景的主题(推断的主题是@android:style/Theme)

我想知道如何纠正这个错误,因为在互联网上检查和检查后,我发现它正在降低应用程序速度,导致它重新加载后台两次以放置此源。

这是我的layout.xml的来源:

<?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:background="@drawable/main"
    android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="120dp"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="20dp"
    android:text="@string/alta1"
    android:textColor="#000"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_marginTop="20dp"
    android:layout_centerHorizontal="true"
    android:text="@string/alta2"
    android:layout_marginLeft="20dp"
    android:textColor="#000"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<Button
    android:id="@+id/continuaralta"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/textView2"
    android:layout_marginRight="50dp"
    android:layout_marginTop="36dp"
    android:textStyle="bold"
    android:background="@drawable/boton"
    android:text="@string/continuar" />

<Button
    android:id="@+id/saliralta"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/continuaralta"
    android:layout_alignBottom="@+id/continuaralta"
    android:layout_marginRight="15dp"
    android:layout_toLeftOf="@+id/continuaralta"
    android:background="@drawable/boton"
    android:textStyle="bold"
    android:text="@string/salir" />

尼尔·塞恩斯伯里,在http://www.earthtoneil.com/ http://www.earthtoneil.com/,说 Romain Guy 已经解决了根本问题http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html。请参阅 Neil 的博客并搜索您的错误消息。然后,前往http://developer.android.com/guide/topics/ui/themes.html http://developer.android.com/guide/topics/ui/themes.html了解如何将背景主题应用到整个应用程序和单个活动。

这种方法至少会导致错误消息不再出现。在我的情况下,进行修复后,需要点击两个箭头图标来刷新 lint 窗口中的警告。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

可能的透支:根元素绘制背景 的相关文章

随机推荐