3.1.4 ImageView控件
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
请把上面的结构改成相对布局
然后有二个imageview控件
一张是背景图片,一张是logo图片(位置在左上角)
<!-- 背景图片 -->
<ImageView
android:id="@+id/image_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/background_image" />
<!-- Logo 图片 -->
<ImageView
android:id="@+id/image_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" <!-- 置顶 -->
android:layout_alignParentStart="true" <!-- 置左 -->
android:layout_marginTop="10dp" <!-- 与顶部距离 -->
android:layout_marginEnd="10dp" <!-- 与右侧距离 -->
android:src="@drawable/logo_image" />
背景图片是bg.png,logo是icon.png,请修正上面的代码
<!-- 背景图片 -->
<ImageView
android:id="@+id/image_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/bg" />
<!-- Logo 图片 -->
<ImageView
android:id="@+id/image_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:src="@drawable/icon" />
uploading-image-934919.png

浙公网安备 33010602011771号