gpt4 book ai didi

android - 您必须在某些设备中提供 layout_width 属性

转载 作者:行者123 更新时间:2023-11-29 00:27:55 27 4
gpt4 key购买 nike

我在我的应用程序中遇到了这个问题,我似乎无法理解它是如何发生的。它只发生在 Samsung Galaxy Y 手机上,我在其他设备上试过这段代码,没问题。

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 文件的 Activity 也是应用程序的主要入口点。

提前致谢。

最佳答案

如果您为特定密度或屏幕尺寸指定了尺寸(或任何其他值或资源),请确保您也在通用目录中定义了它们(即“值”、“可绘制”)

关于android - 您必须在某些设备中提供 layout_width 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18049140/

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