我想这是最简单的活动 xml 代码,但 Android Studio 在悬停在它上面时会给出这个歧义错误,我会忽略它,但 IDE 的布局验证和物理设备的最终结果是所有这些子元素即使在蓝图视图中,第二个 LinerLayout 也根本没有出现。
我已经尝试过类似帖子的解决方案,但对我没有用: 重新启动 IDE 重新启动系统 清理项目 感谢您的帮助。
<?xml version="1.0" encoding="utf-8"?>
<!--1ok-->
<LinearLayout
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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context=".Profile_activity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.constraintlayout.widget.Barrier
android:id="@+id/Barrier_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierAllowsGoneWidgets="false"
app:barrierDirection="top"/>
<ImageView...>
</androidx.constraintlayout.widget.ConstraintLayout>
<LinerLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<LinerLayout...><!--other elements folded inside it like TextVeiw-->
<!--Android message while hovering on it===>"Element LinerLayout is not allowed here"-->
<LinerLayout...><!--other elements folded inside it like TextVeiw-->
<!--Android message while hovering on it===>"Element LinerLayout is not allowed here"-->
</LinerLayout>
</LinearLayout>