【发布时间】:2020-03-02 21:01:53
【问题描述】:
我想要一个带有图像的活动,并在图像下方有一个 viewpager2,它将根据用户的点击而改变。所以我想出了这个活动的布局:
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeActivity" >
<ImageView
android:id="@+id/profile_pic_imageView"
android:layout_width="220dp"
android:layout_height="220dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_logo"/>
<androidx.viewpager2.widget.ViewPager2
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/profile_pic_imageView" />
</androidx.constraintlayout.widget.ConstraintLayout>
但是,它位于 imageview 之上...我需要更改什么?我尝试了 match_parent 和 0dp,但它始终位于图像视图的顶部
【问题讨论】:
标签: android-studio android-constraintlayout android-viewpager2