gpt4 book ai didi

android - 如何将一个 View 的基线对齐到另一个 View 的顶部

转载 作者:行者123 更新时间:2023-11-29 00:09:01 25 4
gpt4 key购买 nike

我需要这样做,其中绿色图标通过其基线与这张白卡的顶部对齐

enter image description here

在我的例子中,我可以将绿色图标的顶部与白卡的顶部对齐。在这种情况下,绿色图标的 layout_marginTop 不允许将其移动到顶部。

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.wearable.view.CardFrame
android:id="@+id/card_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:textColor="@color/black"/>
</android.support.wearable.view.CardFrame>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu"
android:layout_alignRight="@id/card_home"
android:layout_alignTop="@id/card_home"
android:layout_marginBottom="30dp"/>
</RelativeLayout>

enter image description here

最佳答案

你可以试试负margin-top

   <ImageView
...
android:layout_marginTop="-30dp"
.../>

关于android - 如何将一个 View 的基线对齐到另一个 View 的顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31589181/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com