图像查看错误

时间:2016-01-21 15:13:27

标签: java android

我正在尝试为Android设备创建一个应用程序,我需要连续10张图片,它们之间有相同的填充和文字。

我尝试使用填充来执行此操作,但是当我运行图库部分时,应用程序关闭(名称已停止。)。

在我的Logcat中,我收到此错误:

01-21 16:10:34.813: E/AndroidRuntime(641): FATAL EXCEPTION: main 
01-21 16:10:34.813: E/AndroidRuntime(641): android.view.InflateException: Binary XML file line #86: Error inflating class <unknown> 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:760) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at com.haxhibekaj.skenderaj.GalleryFragment.onCreateView(GalleryFragment.java:19) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.Fragment.performCreateView(Fragment.java:1699) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.BackStackRecord.run(BackStackRecord.java:682) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1455) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.os.Handler.handleCallback(Handler.java:725) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.os.Handler.dispatchMessage(Handler.java:92) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.os.Looper.loop(Looper.java:137) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.app.ActivityThread.main(ActivityThread.java:5279) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at java.lang.reflect.Method.invokeNative(Native Method) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at java.lang.reflect.Method.invoke(Method.java:511) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at dalvik.system.NativeStart.main(Native Method) 
01-21 16:10:34.813: E/AndroidRuntime(641): Caused by: java.lang.reflect.InvocationTargetException 
01-21 16:10:34.813: E/AndroidRuntime(641):  at java.lang.reflect.Constructor.constructNative(Native Method) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.view.LayoutInflater.createView(LayoutInflater.java:593) 
01-21 16:10:34.813: E/AndroidRuntime(641):  ... 23 more 
01-21 16:10:34.813: E/AndroidRuntime(641): Caused by: java.lang.OutOfMemoryError 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:817) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.content.res.Resources.loadDrawable(Resources.java:2854) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.content.res.TypedArray.getDrawable(TypedArray.java:602) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.widget.ImageView.<init>(ImageView.java:126) 
01-21 16:10:34.813: E/AndroidRuntime(641):  at android.widget.ImageView.<init>(ImageView.java:116) 
01-21 16:10:34.813: E/AndroidRuntime(641):  ... 26 more

1 个答案:

答案 0 :(得分:0)

导致此问题的主要原因是:java.lang.OutOfMemoryError

您可以使用BitmapFactory调整位图文件的大小,您可以在此链接中找到here