可能透支:根元素绘制背景 [英] Possible overdraw: Root element paints background

查看:164
本文介绍了可能透支:根元素绘制背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,它出现这个警告在Android上的lints:

In my application, it appears this warning on the lints of Android:

可能透支:根元素绘制背景@绘制/主要用
  也描绘了背景主题(推断主题是​​@android:风格/主题)

Possible overdraw: Root element paints background @drawable/main with a theme that also paints a background (inferred theme is @android:style/Theme)

我想知道怎么纠正这个错误,导致检查和互联网上的检查后,我才发现,它在减少应用程序的速度导致它重新加载两次背景把这个源。

I wanna know how to correct this mistake, cause after checking and checking on internet, I just found that it is decreasing application speed cause it reload two times the background to put this source.

这是我的layout.xml来源:

This is the source of my 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/,说罗曼盖伊曾在<一个解决的根本问题href=\"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的博客和搜索您的错误消息。然后,转到<一个href=\"http://developer.android.com/guide/topics/ui/themes.html\">http://developer.android.com/guide/topics/ui/themes.html要学会背景主题应用到应用程序作为一个整体和个人的活动。

Neil Sainsbury, at http://www.earthtoneil.com/, says that Romain Guy has addressed the underlying issue at http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html. See Neil's blog and search for your error message. Then, go to http://developer.android.com/guide/topics/ui/themes.html to learn how to apply background themes to the app as a whole and to individual activities.

这做法至少会导致错误消息不再出现。打双箭头图标刷新皮棉窗口的警告作出必要的修正在我的情况后。

This approach will at least cause the error message to no longer appear. Hitting the two-arrows icon to refresh the warnings in the lint window after making the fix was necessary in my case.

这篇关于可能透支:根元素绘制背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆