我正在使用ConstraintLayout,想要将TextView放在ImageView之上。但是我无法在ConstraintLayout中找到这个功能。最初的回答。
在上述代码中,TextView被隐藏在ImageView下面。我该如何将文本放置在图像的顶部?翻译结果为:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="com.example.sayani.myApp.MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="4dp"
android:layout_marginEnd="4dp"
android:layout_marginStart="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/image1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="240dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="@+id/imageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"/>
</android.support.constraint.ConstraintLayout>
在上述代码中,TextView被隐藏在ImageView下面。我该如何将文本放置在图像的顶部?翻译结果为:
在以上代码中,TextView被隐藏在ImageView下方。
如何将文本放置在图片上方?