0

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>
rabbitt
  • 2,558
  • 8
  • 28
  • 41
  • The answer to your question depends on what goes inside the layout with text. If it's a list of items, you may consider using a ListView. Otherwise, you may want to just create a bunch of TextViews either in your xml file or programmatically, and arrange them using the RelativeLayout. – Jodes May 15 '11 at 05:51
  • It will just be strings of text, an app name, a developer name, a short instructional sentence and, a what's new in this app version blurb. – rabbitt May 15 '11 at 05:55

1 Answers1

1

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.

James andresakis
  • 5,335
  • 9
  • 53
  • 88
  • So at the moment I have a LinearLayout encompassing the whole screen, then two relative layouts inside it. You are saying have it like this right?: LinearLayout vertically. LinearLayout horizontally. RelativeLayout. close RelativeLayout. RelativeLayout. close RelativeLayout. RelativeLayout. close RelativeLayout. close LinearLayout. close LinearLayout. – rabbitt May 15 '11 at 07:37
  • Im not totally sure if Im fully understanding you but what I was suggesting is that you declare in each relative layout that it is to be aligned to the left or right of the parent and then use the padding to get it to where you want. Also you may want to use dpi instead of pix as it will auto size itself to the screen density of each device. Using the xml for the layout is definitely quicker but for full control you may want to dig up how to do the layout in java. – James andresakis May 15 '11 at 07:58
  • You would write it out like this.....I think ;) Now remember that I cant remember if this draws the content to the right of the relative layout or if it draws the relative layout to the right of its parent view but I do know that it is something like that that will do what your trying to do. – James andresakis May 15 '11 at 08:04
  • Yep, I totally get you. Everything sounds good, and I'll try it later when I have some time. Could you please elaborate on dpi compared to pix. I have been wondering about device compatablity? Keep in mind this is for Honeycomb and up, once all functions are working I am going to write a different app for phone screen size. – rabbitt May 15 '11 at 08:12
  • http://stackoverflow.com/questions/2025282/difference-of-px-dp-dip-and-sp-in-android take a look at what these guys were talking about in this thread I posted. – James andresakis May 15 '11 at 08:28