gpt4 book ai didi

android - 如何修复在构建项目时收到的 atp0000 错误?

转载 作者:行者123 更新时间:2023-11-30 05:06:30 25 4
gpt4 key购买 nike

我正在使用 axml 设计器来构建 UI。我在 relativeLayout 的 4 个部分上分开屏幕。我想在另一个 2 之间找到一个,当添加 layout_above = "@id/myBottomView"时,我收到编译错误(见下文)。但是设计师画的一切都是对的。我该如何解决?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_centerInParent="true"
android:background="#1212ed"
android:id="@+id/view1">
</View>
<RelativeLayout
android:id="@+id/topView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/historyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
android:text="History" />
<TextView
android:id="@+id/label"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="eFinder"/>
<Button
android:id="@+id/libraryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dip"
android:text="Library" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/addScanView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:layout_below="@id/view1"
android:layout_above="@id/myBottomView">
<TextView
android:id="@+id/scanCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="10/5 scans"/>
<Button
android:id="@+id/addScansButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add Scans"
android:layout_below="@id/scanCounter"
android:layout_centerHorizontal="true"
android:layout_marginTop="9.0dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/addScansButton"
android:gravity="bottom"
android:text="Tap to find E"
android:layout_alignParentBottom="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/myBottomView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10.0dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dip"
android:text="share" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dip"
android:text="options" />
</RelativeLayout>
</RelativeLayout>

这是给我设计师看的,它是正确的,但有构建错误:

enter image description here

我收到错误://Resources/layout/Main.axml(0,0):错误 APT0000:找不到与给定名称匹配的资源(在“layout_above”中值为“@id/myBottomView”)。 (APT0000)

最佳答案

将您的 RelativeLayout (myBottomView) 元素移动到引用它的元素 (addScanView) 上方,从上到下分析布局底部。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/topView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</RelativeLayout>
<RelativeLayout
android:id="@+id/myBottomView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10.0dp">
</RelativeLayout>
<RelativeLayout
android:id="@+id/addScanView"
android:layout_below="@id/view1"
android:layout_above="@id/myBottomView">
</RelativeLayout>
</RelativeLayout>

关于android - 如何修复在构建项目时收到的 atp0000 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54493206/

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