java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class

  

异常解决方案:

是因为设置background的图片太大了,造成了内存溢出,在Activity设置onCreate里面加载布局的时候出错

不要设置跟布局的background为图片,可以用FrameLayout和ImageView实现相同的效果。

Option 1:

Create different perfect images for different dpi and place them in related drawable folder. Then set

android:background="@drawable/your_image

Option 2:

Add a single large image. Use FrameLayout. As a first child add an ImageView. Set the following in your ImageView.

android:src="@drawable/your_image"
android:scaleType = "centerCrop"



参考噢:http://stackoverflow.com/questions/16135984/full-screen-background-image-in-an-activity
原文地址:https://www.cnblogs.com/spring87/p/5206723.html