外层套一个LinearLayout控制,android:layout_marginTop="100dp"放到约束布局中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300px"
>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/frameLayout2"
android:layout_marginTop="100dp"
android:background="@drawable/backg_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>