在我的应用程序中,它出现在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" />
Run Code Online (Sandbox Code Playgroud)
Neil Sainsbury在http://www.earthtoneil.com/上说,Romain Guy在http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html上解决了潜在的问题..查看Neil的博客并搜索您的错误消息.然后,转到http://developer.android.com/guide/topics/ui/themes.html,了解如何将背景主题应用于整个应用程序以及各个活动.
这种方法至少会导致错误消息不再出现.在我的情况下,在进行修复后点击双箭头图标刷新lint窗口中的警告是必要的.
| 归档时间: |
|
| 查看次数: |
9819 次 |
| 最近记录: |