1
    <?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>

その 3 つの非常に小さい JPEGS 1 つは背景で、他の 2 つはボタンです。実行時エラーが発生することはわかっていますが、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
4

2 に答える 2

1

同じxmlファイルを使用します。

開いているものを変更すると、使用したすべての画像または画像が変更されます。AndroidはPNGのみで完全に機能するため、.PNG形式で変更し、同じ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 
于 2012-11-28T04:04:13.233 に答える
0

はい、描画可能な画像を jpeg ではなく png 画像に置き換えることができます。また、発生している実行時エラーを投稿してください。

于 2012-11-28T04:25:08.117 に答える