您必须在某些设备中提供layout_width属性 [英] You must supply a layout_width attribute in some devices
问题描述
我的应用程序中遇到了这个问题,我似乎无法理解它是如何发生的.它仅出现在Samsung Galaxy Y手机中,我在其他设备上尝试了此代码,没关系.
I am experiencing this problem in my app and I can't seem to understand how it happen. It only occurs in Samsung Galaxy Y phone, I tried this code in other devices and it is ok.
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:
Can anyone help me with this? btw, here is the xml in question:
<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文件的活动也是应用程序的主要入口点.
Also the activity for this xml file is the main entry point of the app.
提前谢谢.
推荐答案
如果您为特定的密度或屏幕尺寸指定了尺寸(或任何其他值或资源),请确保在通用目录(即值",可绘制")
If you have dimensions (or any other values or resources) specified for particular densities or screen sizes, make sure you also have them defined in the generic directory (i.e. "values", "drawable")
这篇关于您必须在某些设备中提供layout_width属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!