Askerman
Askerman

Reputation: 847

Positioning to bottom-right in an absoluteLayout in xamarin.android

I have an absolute layout like this

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
       //stuff
    </LinearLayout>
    <Button
        android:text="test"
        android:textStyle="bold"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_x="10dp"
        android:layout_y="10dp"
         />
</AbsoluteLayout>

It takes a button and positions it to a top left position at 10dp from top of the screen and 10dp from the left of the screen.

I need to add another button there and position it to the bottom right of the screen, but I do not know how to set the positions (layout_x and y) to be calculated from bottom and right positions, they are currently calculated from the top and left.

Is this possible? I would be even willing to use relative or similar layout, instead of the absolute, if it would solve the problem.

Upvotes: 2

Views: 2179

Answers (1)

Mohamed Krayem
Mohamed Krayem

Reputation: 428

AbsoluteLayout is deprecated since API3.

you can use RelativeLayout instead and set android:layout_alignParentBottom="true" and android:layout_alignParentRight="true" for the Button.

    <Button
    android:text="Button"
    android:textStyle="bold"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" />

Upvotes: 2

Related Questions