您的位置:首页 > 移动开发 > Android开发

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

2016-02-22 12:18 816 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: