可能的过度绘制:根元素绘制我无法解析的背景

fab*_*bio 1 android android-fragments android-view

你好,我有这个简单的观点:

<?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/lavagna_verticale"
     android:orientation="vertical" >	
     
      <TextView
          android:id="@+id/voto_lavagna"
          android:layout_width="235sp"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
         	  android:layout_centerVertical="true"
          android:gravity="center"
          android:textColor="@color/bianco"
          android:textSize="30sp"
          android:textStyle="bold"/>	    	 
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

我可以将图像显示到背景中,但需要进行 lint 检查:

Possible overdraw: Root element paints background @drawable/lavagna_verticale with a 
 theme that also paints a background (inferred theme is @android:style/Theme.Holo)
Run Code Online (Sandbox Code Playgroud)

我创建了一种新风格:

    <style name="SfondoLavagnaVerticale" parent="@style/Theme.AppCompat">
        <item name="android:background">@drawable/lavagna_verticale</item>
	</style>
Run Code Online (Sandbox Code Playgroud)

并改变我的看法:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:theme="@style/SfondoLavagnaVerticale"
     android:orientation="vertical" >	
  ..
  ....
  .....
Run Code Online (Sandbox Code Playgroud)

现在我没有 lint 错误,但我无法显示我的图像我能做什么?

Dom*_*icz 5

代替

android:theme="@style/SfondoLavagnaVerticale"
Run Code Online (Sandbox Code Playgroud)

style="@style/SfondoLavagnaVerticale"
Run Code Online (Sandbox Code Playgroud)

在你的相对布局中

解决 lint 错误。跳转此处“可能的透支:根元素绘制背景”