如何将imageview的中心与viewgroup的顶部对齐? 我想将圆形图像(红色圆圈)的中心与视图组(绿色矩形)的顶部对齐
答案 0 :(得分:1)
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/some_layout"
android:layout_width="0dp"
android:layout_height="200dp"
android:background="#77ff77"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginEnd="8dp"
android:src="#f00"
app:layout_constraintBottom_toTopOf="@id/some_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/some_layout" />
</android.support.constraint.ConstraintLayout>
答案 1 :(得分:-1)
您可以尝试一下。
<View
android:background="@android:color/black"
android:layout_alignParentBottom="true"
android:id="@+id/bottomView"
android:layout_width="match_parent"
android:layout_height="200dp"/>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginBottom="-50dp"
android:layout_above="@+id/bottomView"
android:layout_alignParentRight="true"
/>