java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.L

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.L相关的知识,希望对你有一定的参考价值。

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

以上是关于java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.L的主要内容,如果未能解决你的问题,请参考以下文章

Android Studio 按钮导致崩溃

添加 ImageView 时应用程序崩溃?