如何将图像视图的中心对齐到视图组的顶部?我想将圆形图像(红色圆圈)的中心对齐到视图组(绿色矩形)的顶部
2 回答
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>
于 2018-07-26T12:12:32.423 回答
-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"
/>
于 2018-07-26T12:07:04.083 回答