gpt4 book ai didi

android - 虚拟机重载? LinearLayout背景图片

转载 作者:行者123 更新时间:2023-11-30 03:54:16 27 4
gpt4 key购买 nike

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/background1">

<ImageButton
android:id="@+id/make"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:scaleType="fitXY"
android:src="@drawable/button1" >
</ImageButton>

<ImageButton
android:id="@+id/see"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:scaleType="fitXY"
android:src="@drawable/button2" >
</ImageButton>



它的三个非常小的JPEGS是一个背景,另外两个是按钮,我知道我遇到了运行时错误,但是当我为LinearLayout删除android:background时,它运行正常,我在做什么错?

    11-27 23:25:37.464: D/dalvikvm(422): GC_EXTERNAL_ALLOC freed 49K, 50% free        2742K/5379K, external 1625K/2137K, paused 74ms
11-27 23:25:38.624: D/dalvikvm(422): GC_EXTERNAL_ALLOC freed 2K, 50% free 2740K/5379K, external 12425K/14473K, paused 99ms
11-27 23:25:38.674: E/dalvikvm-heap(422): 22118400-byte external allocation too large for this process.
11-27 23:25:38.734: E/GraphicsJNI(422): VM won't let us allocate 22118400 bytes
11-27 23:25:38.734: D/dalvikvm(422): GC_FOR_MALLOC freed 0K, 50% free 2740K/5379K, external 12425K/14473K, paused 44ms
11-27 23:25:38.744: D/AndroidRuntime(422): Shutting down VM
11-27 23:25:38.744: W/dalvikvm(422): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-27 23:25:38.784: E/AndroidRuntime(422): FATAL EXCEPTION: main
11-27 23:25:38.784: E/AndroidRuntime(422): java.lang.RuntimeException: Unable to start activity ComponentInfo{genie.lamp.rub/genie.lamp.rub.FirstScreen}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.os.Looper.loop(Looper.java:130)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.ActivityThread.main(ActivityThread.java:3683)
11-27 23:25:38.784: E/AndroidRuntime(422): at java.lang.reflect.Method.invokeNative(Native Method)
11-27 23:25:38.784: E/AndroidRuntime(422): at java.lang.reflect.Method.invoke(Method.java:507)
11-27 23:25:38.784: E/AndroidRuntime(422): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-27 23:25:38.784: E/AndroidRuntime(422): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-27 23:25:38.784: E/AndroidRuntime(422): at dalvik.system.NativeStart.main(Native Method)
11-27 23:25:38.784: E/AndroidRuntime(422): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
11-27 23:25:38.784: E/AndroidRuntime(422): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java: 56)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-27 23:25:38.784: E/AndroidRuntime(422): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.Activity.setContentView(Activity.java:1657)
11-27 23:25:38.784: E/AndroidRuntime(422): at genie.lamp.rub.FirstScreen.onCreate(FirstScreen.java:16)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-27 23:25:38.784: E/AndroidRuntime(422): ... 11 more
11-27 23:25:38.784: E/AndroidRuntime(422): Caused by: java.lang.reflect.InvocationTargetException
11-27 23:25:38.784: E/AndroidRuntime(422): at java.lang.reflect.Constructor.constructNative(Native Method)
11-27 23:25:38.784: E/AndroidRuntime(422): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
11-27 23:25:38.784: E/AndroidRuntime(422): ... 21 more
11-27 23:25:38.784: E/AndroidRuntime(422): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.Bitmap.nativeCreate(Native Method)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:473)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.content.res.Resources.loadDrawable(Resources.java:1709)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.View.<init>(View.java:1951)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.View.<init>(View.java:1899)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.view.ViewGroup.<init>(ViewGroup.java:286)
11-27 23:25:38.784: E/AndroidRuntime(422): at android.widget.LinearLayout.<init>(LinearLayout.java:120)
11-27 23:25:38.784: E/AndroidRuntime(422): ... 24 more
11-27 23:25:41.264: I/Process(422): Sending signal. PID: 422 SIG: 9

最佳答案

使用相同的xml文件。

并更改打开的内容,更改您使用的所有图片或图像。在PNG格式中进行更改,因为仅用PNG即可实现Android完美的工作
并使用相同的XML,但只能更改可拖动文件夹中的所有图片或图像。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:background="@drawable/background1">

<ImageButton
android:id="@+id/make"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:scaleType="fitXY"
android:src="@drawable/button1" >
</ImageButton>

<ImageButton
android:id="@+id/see"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:scaleType="fitXY"
android:src="@drawable/button2" >
</ImageButton>


抽9张补丁

http://developer.android.com/tools/help/draw9patch.html 

关于android - 虚拟机重载? LinearLayout背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13597544/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com