anony_root
anony_root

Reputation: 1527

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.

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 />.

How should I construct my XML file?

Upvotes: 3

Views: 9387

Answers (2)

FoamyGuy
FoamyGuy

Reputation: 46846

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. This value should be roughly half the size of your small View.

Upvotes: 8

code_finder
code_finder

Reputation: 1370

Use android:layout_alignParent & adjust android:layout_margin to get the view what ever you want...

Upvotes: 0

Related Questions