rabbitt
rabbitt

Reputation: 2598

How can I achieve this layout?

I am trying to achieve this in an android app layout. enter image description here

So far I have managed to get the buttons the way I wish, but I am having trouble working out how I am going to implement the divider and the layout on the right side of it.

Here is what I have so far:

<?xml version="1.0" encoding="utf-8"?>
<!-- this is main activity's layout. a main menu of sorts. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:gravity="center" android:background="@drawable/background">
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/layout_maintest2_relativelayoutleft">
    <Button android:text="@string/string_main_NewCalculation" android:drawableLeft="@drawable/calculator5" android:onClick="onClickButton_NewCalculation" android:id="@+id/button_main_NewCalculation" android:layout_width="300px" android:layout_height="90px" android:drawablePadding="0px"></Button>
    <Button android:text="@string/string_main_Help" android:drawableLeft="@drawable/question" android:onClick="onClickButton_Help" android:id="@+id/button_main_Help" android:layout_width="150px" android:layout_height="90px" android:drawablePadding="0px" android:layout_below="@id/button_main_NewCalculation"></Button>
    <Button android:text="@string/string_main_Share" android:drawableLeft="@drawable/share" android:onClick="onClickButton_Share" android:id="@+id/button_main_Share" android:layout_width="150px" android:layout_height="90px" android:drawablePadding="0px" android:layout_below="@id/button_main_NewCalculation" android:layout_toRightOf="@id/button_main_Help"></Button>
</RelativeLayout>
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/layout_maintest2_relativelayoutright" android:layout_toRightOf="@id/layout_maintest2_relativelayoutleft" android:layout_alignTop="@id/layout_maintest2_relativelayoutleft">
    <TextView android:layout_width="wrap_content" android:textSize="24px" android:textStyle="bold" android:layout_height="match_parent" android:id="@+id/textView_calculator_CalculatorTitle" android:text="@string/string_calculator_CalculatorTitle"></TextView>
</RelativeLayout>
</LinearLayout>

Upvotes: 0

Views: 517

Answers (1)

James andresakis
James andresakis

Reputation: 5415

Its hard to tell from the image you uploaded but are you trying to keep the two relative layouts side by side?

You can try to position the layouts by declaring them to be drawn to one side of the parent or the other. I cant remember off the top of my head at the moment and I know thats a crappy answer but I think the answer is somewhere in here

http://developer.android.com/guide/topics/ui/layout-objects.html

Take a look at the android:layout_alignParentRight="true" declaration.

Im pretty sure I used something similar to position multiple views and buttons in the same parent before. Try it out and when I get back to my work computer on monday Ill look through my projects and see which one I know works the best.

Upvotes: 1

Related Questions