1
我在我的應用中遇到此問題,我似乎無法理解它是如何發生的。它只發生在三星Galaxy Y手機上,我在其他設備上試過這個代碼,並沒有問題。您必須在某些設備中提供layout_width屬性
java.lang.RuntimeException: Unable to start activity ComponentInfo{jpac.remaster.gtc/jpac.remaster.gtc.GTCSplash}: java.lang.RuntimeException: Binary XML file line #7: You must supply a layout_width attribute.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3735)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:662)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Binary XML file line #7: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:491)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:3598)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:3678)
at android.widget.RelativeLayout$LayoutParams.<init>(RelativeLayout.java:1169)
at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:998)
at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:74)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:625)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
at android.app.Activity.setContentView(Activity.java:1657)
at jpac.remaster.gtc.GTCSplash.onCreate(GTCSplash.java:33)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
... 11 more
任何人都可以幫助我嗎?順便說一句,這是有問題的XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/tuna" >
<ImageView
android:id="@+id/dev_logo"
android:layout_width="@dimen/speech_height"
android:layout_height="@dimen/badge_height"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:contentDescription="@string/empty"
android:scaleType="centerInside"
android:src="@drawable/logo_dark" />
</RelativeLayout>
此外,該XML文件的活動是該應用程序的主要入口點。
在此先感謝。
你所有dpi的佈局和尺寸都相同? – msh
是的,感覺就像'@ dimen/speech_height'在某些情況下可能無法使用。 – CommonsWare
哦。我明白了,我想我現在得到它了。順便說一句,Galaxy Y是一個小屏幕設備?可能這就是問題,因爲我沒有dimension.xml來實現小值 – kishidp