0

I have a layout in my app that has four image buttons. I want the last two image buttons, the reload and stop buttons to be on the right side of the screen, with empty space between the two buttons. How would I achieve this? I've heard of Space but that was added in API Level 14 and I'd like to maintain my minSdkVersion of 8. image buttons in layout

Sega dude
  • 1,103
  • 3
  • 12
  • 29

3 Answers3

0

create a linear layout and add these two buttons into the linear layout with orientation horizontal.. and position the linearlayout to the right side of the parent layout which might be relative layout with alignParentRight = "true" - hope it helps.. if you dont get it tell me to provide codes ??

EDIT 1 : CODE

 <RelativeLayout 
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

  </LinearLayout>

</RelativeLayout>

post this relatively to the layout you already have and remove the two buttons you want to align to the right replace it with the two buttons here..thats it.. let me know whats upp

Elltz
  • 10,730
  • 4
  • 31
  • 59
0

You could probably use a RelativeLayout to achieve this by getting advantage of the layout properties in the xml. You could align the X button/image to the bottom left of the parent and then align the refresh button to the right of the X button.

Link to useful information - http://developer.android.com/guide/topics/ui/layout/relative.html

Amilcar Andrade
  • 1,131
  • 9
  • 16
0

Put all the 4 buttons inside a Relative layout. Each 2 buttons should have a linear layout parent. 1st linear layout should have alignParentLeft = true attribute, while the 2nd linear layout(container of the reload and stop) should have alignParentRight = true attribute.

Or you can simply put it all together on the relative layout.. then align it manually. Use to rightOf, to LeftOf attributes.

Hope this helps! :)

shibapoo
  • 1,909
  • 3
  • 16
  • 22