可能的透支:根元素绘制背景我无法解决

时间:2015-02-06 15:03:56

标签: 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>

我可以将图像显示到背景中,但是使用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)

我创造了一种新风格:

    <style name="SfondoLavagnaVerticale" parent="@style/Theme.AppCompat">
        <item name="android:background">@drawable/lavagna_verticale</item>
	</style>

并改变我的观点:

<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" >	
  ..
  ....
  .....

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

1 个答案:

答案 0 :(得分:4)

替换

android:theme="@style/SfondoLavagnaVerticale"

使用

style="@style/SfondoLavagnaVerticale"
在RelativeLayout中

解决lint错误。跳到这里"Possible overdraw: Root element paints background "

相关问题