简体   繁体   English

如何将布局中心放在另一个布局的右上角?

[英]How to place center of layout on top-right corner of another layout?

I have:我有:

<RelativeLayout style="@style/w_w"
  android:gravity="top|center" 
  android:layout_marginBottom="10sp">
    <ImageView android:id="@+id/icon" style="@style/w_w"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@drawable/icon"
    /> 
    <TextView android:text="F" android:id="@+id/temp" style="@style/w_w"
        android:textColor="#ffffff"
        android:textSize="10sp"
        android:textStyle="bold"
        android:gravity="top|center"/>
</RelativeLayout>

@style/w_w - layout_height="wrap_content"=layout_width. @style/w_w - layout_height="wrap_content"=layout_width。

Now <TextView /> 's right-top is in right-top corner of <RelativeLayout /> , but I'd like to place <TextView /> 's center in right-top corner of <ImageViwq /> .现在<TextView />的右上角位于<RelativeLayout />右上角,但我想将<TextView />的中心放在<ImageViwq />右上角。

How should I construct my XML file?我应该如何构建我的 XML 文件?

Use this on your small view在你的小视图上使用这个

android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="-5dip"
android:layout_marginRight="-5dip"

Adjust the "-5dip"s if need be.如果需要,调整“-5dip”。 This value should be roughly half the size of your small View.这个值应该大约是你的小视图大小的一半。

使用android:layout_alignParent并调整android:layout_margin以获得您想要的视图...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android-如何使一个视图的中心位于列表项布局内另一视图的右上角 - Android - How to make one view's center on another view's top right corner inside list item layout 我如何将相对布局中的视图与右上角对齐 - How do i align a view in RelativeLayout to top-right corner 将按钮移动到半透明布局的右上角位置 - Move button to top-right position in translucent layout 将 ImageView 中的图像与右上角对齐 - Aligning an image in an ImageView to the top-right corner 将标签放在右上角 - Putting a label on the top-right corner Android版式图片右上角 - Android Layout Image Top Right Corner 如何在 CardView 的右上角 position 上放置一个图标? - How do I place an icon on top-right position of CardView? 如何在相对布局中将 Textview 放置在 Imageview 的右侧和中心 - How to place a Textview to the right and center of the Imageview in Relative Layout 如何在父母布局的右上角添加两个浮动操作按钮(一半为内部布局,一半为外部),并在单击时显示 - How to add two floating action button on top-right of parrent layout (half insidelayout, and half outside), and show on click 如何在布局的一角放置一个圆形的按钮 - how to place a rounded button at corner of a layout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM