布局高度错误350(Android Studio)
当我尝试构建应用程序时,出现以下错误:布局高度错误350(Android Studio),android,xml,android-layout,Android,Xml,Android Layout,当我尝试构建应用程序时,出现以下错误: error: '350' is incompatible with attribute android:layout_height (attr) dimension|enum [fill_parent=4294967295, match_parent=4294967295, wrap_content=4294967294]. Message{kind=ERROR, text=error: '350' is incompatible with attribu
error: '350' is incompatible with attribute android:layout_height (attr) dimension|enum [fill_parent=4294967295, match_parent=4294967295, wrap_content=4294967294].
Message{kind=ERROR, text=error: '350' is incompatible with attribute android:layout_height (attr) dimension|enum [fill_parent=4294967295, match_parent=4294967295, wrap_content=4294967294]., sources=[C:\Users\chris\Documents\GitHub\IFB398\MiBaseApplication\app\src\main\res\layout\activity_login_screen.xml:30], original message=, tool name=Optional.of(AAPT)}
我使用的是Android studio,我对这一切都很陌生
编辑1:
<EditText
android:id="@+id/UsernameEditText"
android:layout_width="307dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Username"
android:inputType="textPersonName"
android:textColor="@android:color/background_light"
android:textColorHint="@android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.513"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.55" />
<ImageView
android:id="@+id/LogoImageView"
android:layout_width="350"
android:layout_height="350"
android:layout_marginBottom="6dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@mipmap/mibaselogo" />
<EditText
android:id="@+id/PasswordEditText"
android:layout_width="309dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColor="@android:color/background_light"
android:textColorHint="@android:color/darker_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.514"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/UsernameEditText"
app:layout_constraintVertical_bias="0.085" />
我没有添加所有代码。只是错误上方和下方的部分。(我假设错误出现在第30行,这是图像的开头。您必须给出有效的高度 使用匹配父项或换行内容或有效维度
android:layout_height="350dp" //right one
您可能错误地给出了错误的高度
android:layout_height="350" //wrong one
你必须给出有效的高度 使用匹配父项或换行内容或有效维度
android:layout_height="350dp" //right one
您可能错误地给出了错误的高度
android:layout_height="350" //wrong one
您需要指定维度单位,如dp或dip。对于android:layout\u height属性,请使用“350dp”而不是“350”。
希望这能有所帮助。您需要指定维度单位,如dp或dip。对于android:layout\u height属性,使用“350dp”而不是“350”。
希望这有帮助。检查您的xml代码
<RelativeLayout
android:layout_width="match_parent"
android:background="@drawable/button_selector"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_height="40dp">
<Button
android:id="@+id/button_select"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Select"
android:background="#d57200"
android:layout_centerInParent="true"
android:textSize="18dp"
android:textColor="#fff"
android:textAllCaps="false"/>
</RelativeLayout>
我认为您没有给出有效的高度和宽度,请检查您的xml代码
<RelativeLayout
android:layout_width="match_parent"
android:background="@drawable/button_selector"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_height="40dp">
<Button
android:id="@+id/button_select"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="Select"
android:background="#d57200"
android:layout_centerInParent="true"
android:textSize="18dp"
android:textColor="#fff"
android:textAllCaps="false"/>
</RelativeLayout>
我认为您没有给出有效的高度和宽度,请检查您的xml代码必须使用特定的尺寸,如dip或dp。更新代码:
<ImageView
android:id="@+id/LogoImageView"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_marginBottom="6dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@mipmap/mibaselogo" />
必须使用特定尺寸,如dip或dp。更新代码:
<ImageView
android:id="@+id/LogoImageView"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_marginBottom="6dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@mipmap/mibaselogo" />
如果我想指定一个百分比怎么办?我收到以下消息: 错误APT2259:“50%”与属性高度(attr)不兼容 维度
如果我想指定一个百分比怎么办?我收到以下消息: 错误APT2259:“50%”与属性高度(attr)不兼容 维度
发布您的XML代码。发布活动\登录\屏幕。XML发布您的XML代码。共享您的XML代码您不应该使用硬编码的宽度和高度值发布您的XML代码。发布活动\登录\屏幕。XML发布您的XML代码。共享您的XML代码您不应该使用硬编码的宽度和高度值