android.view.inflateexception binary xml file line #1 error inflating class android.widget.relativeLayout

前端 未结 7 1274
春和景丽
春和景丽 2021-02-07 07:56

I am new in android.
I just made a new layout with one text bar and 2 buttons but it didn\'t work, I am posting the stack trace and my relative layout file any idea about th

7条回答
  •  遇见更好的自我
    2021-02-07 08:32

    this line is indicating the first line of the layout:

    android.view.InflateException: Binary XML file line #1: Error inflating class 
    

    and at the first line there is Relative layout declaration:

    So The error is on android:background, and This is not the correct way to set background of layout:

    android:background="@layout/activity_main"
    

    it should be a color or drawable image

    android:background="@color/backgroundColor" or android:background="#012345"

    or

    android:background="@drawable/backgroundimg"
    

提交回复
热议问题