在上图中,我必须将这些点(在XML中为空View )与其上方图标的中心对齐
下面的代码是我的回收器视图,其中包含视图的
<androidx.core.widget.NestedScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/itemImage">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nestedRecyclerView"/>
</androidx.core.widget.NestedScrollView>
上面的代码是图标
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/itemImage"
android:src="@drawable/ic_glucose"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
现在我需要将"NestedScrollView“对齐到"ImageView”的中心,这样这些点就可以对齐到图标的中心。
如果我设置
app:layout_constraintLeft_toLeftOf="nestedScrollView"
它将它对齐到完整的左侧,但我希望它对齐到图标的中心
我该怎么做,有什么建议吗?
发布于 2021-07-21 21:25:57
不可能直接将NestedScrollView的左侧与ImageView的中心对齐,但有一种方法。
您可以将空白视图与ImageView的中心(ImageView的右至右和左至左)对齐。然后,您的NestedScrollView可以简单地与这个居中视图对齐,通过将RecyclerView对齐到NestedScrollView的左侧,您将获得所需的结果。
https://stackoverflow.com/questions/68470264
复制相似问题