没有方便的定位方式,所有控件都会默认的摆放在布局的左上角。有叠加效果。调整位置通过对齐方式调整
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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!"
android:textColor="#444444"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher"/>
<!--因为ImageView在TextView后面所以图片压在文字上面-->
</FrameLayout>

本文介绍如何在Android布局中避免控件默认放置在左上角的问题,通过使用对齐约束调整控件位置,解决图片遮挡文字的叠放问题。
909

被折叠的 条评论
为什么被折叠?



