gpt4 book ai didi

android - (Android Studio)在包(我的东西)中找不到属性'layout_constraint(所有em)的资源标识符

转载 作者:行者123 更新时间:2023-11-29 01:09:48 28 4
gpt4 key购买 nike

使用 Android Studio 创建游戏,我正在尝试创建开始屏幕菜单 XML。我的意思是我们的教授给了我们一份直接复印件,我照做了。

但是,我收到以下错误:

Error:(11) No resource identifier found for attribute 'layout_constraintHorizontal_bias' in package 'edu.udel.myname.FlappyBird'
C:\Users\firstlast\AndroidStudioProjects\FlappyBird\app\src\main\res\layout\activity_bird.xml
Error:(11) No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'edu.udel.myname.FlappyBird'
Error:(11) No resource identifier found for attribute 'layout_constraintRight_toRightOf' in package 'edu.udel.myname.FlappyBird'
Error:(11) No resource identi`fier found for attribute 'layout_constraintTop_toTopOf' in package 'edu.udel.myname.FlappyBird'
Error:(22) No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'edu.udel.myname.FlappyBird'
Error:(22) No resource identifier found for attribute 'layout_constraintTop_toBottomOf' in package 'edu.udel.myname.FlappyBird'
C:\Users\firstlast\AndroidStudioProjects\FlappyBird\app\build\intermediates\res\merged\debug\layout\activity_bird.xml
Error:(11) No resource identifier found for attribute 'layout_constraintHorizontal_bias' in package 'edu.udel.myname.FlappyBird'
Error:(11) No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'edu.udel.myname.FlappyBird'
Error:(11) No resource identifier found for attribute 'layout_constraintRight_toRightOf' in package 'edu.udel.myname.FlappyBird'
Error:(11) No resource identifier found for attribute 'layout_constraintTop_toTopOf' in package 'edu.udel.myname.FlappyBird'
Error:(22) No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'edu.udel.myname.FlappyBird'
Error:(22) No resource identifier found for attribute 'layout_constraintTop_toBottomOf' in package 'edu.udel.myname.FlappyBird'
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

XML 文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1.0"
tools:context="edu.udel.myname.FlappyBird.bird.FlappyBirdActivity">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:src="@drawable/frame_1"
android:layout_weight="0.4"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/highScores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text=""
android:layout_weight="0.2"
android:layout_gravity="center"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
android:layout_marginStart="16dp" />

<Button
android:id="@+id/play"
android:layout_width="wrap_content"
android:layout_height="12dp"
android:text="Play"
android:layout_weight="0.1"
android:layout_gravity="center"/>

<Button
android:id="@+id/demo"
android:layout_width="wrap_content"
android:layout_height="12dp"
android:text="Demo"
android:layout_weight="0.1"
android:layout_gravity="center"/>

<Button
android:id="@+id/instructions"
android:layout_width="wrap_content"
android:layout_height="12dp"
android:text="Instructions"
android:layout_weight="0.1"
android:layout_gravity="center"/>

<Button
android:id="@+id/quit"
android:layout_width="wrap_content"
android:layout_height="12dp"
android:text="Quit"
android:layout_weight="0.1"
android:layout_gravity="center"/>


</LinearLayout>

最佳答案

属性“layout_constraintHorizo​​ntal_bias”用于 ConstraintLayout .但是,在您的布局文件中,有一个 LinearLayout。

尝试用 ConstraintLayout 替换 LinearLayout。

您可能还需要添加

compile 'com.android.support.constraint:constraint-layout:1.0.2'

到此应用模块的 build.gradle 文件中的依赖项 block 。

关于android - (Android Studio)在包(我的东西)中找不到属性'layout_constraint(所有em)的资源标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43991347/

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