Android 中的相对布局 - Centerof

问题描述 投票:0回答:1

在相对视图组中,我们可以将一个视图放置在另一个视图之上或之下:“layout_above”和“layout_below”。 等等...

现在,我遇到的问题是,如果我想将一个视图放置在另一个视图的中心(不一定位于父视图的中心),我该怎么办?

Like This

当然,它可以使用边距来实现,但它不能提供精确的修复,并且可能会很烦人......

android xml kotlin android-viewgroup
1个回答
0
投票
<...
    android:id="@id/View_2"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_toLeftOf="@+id/View_1"
    android:layout_toRightOf="@+id/View_1"
    ..../>
© www.soinside.com 2019 - 2024. All rights reserved.