0

In Android I'm trying to get a layout looking like this image using xml.

enter image description here

What I've been trying to do is to separate the view vertical into two parts. One for the blue part and one for the white. For the blue part I use a shape as background to get the gradient and for the white part just a white background. It works good for the "Title" and "Some text" part. But as the image view should overlay both layouts it isn't working.

I can't figure out how to setup the xml layout to get it working, any ideas?

Martin
  • 7,190
  • 9
  • 40
  • 48

2 Answers2

1

I would do it like this:

<RelativeLayout>
    <TextView 
        android:id="@+id/title"
        android:layout_alignParentTop="true"
        android:text="title"
        />
    <TextView 
        android:layout_below="@id/title"
        android:layout_alignParentBottom="true"
        android:text="some text here"
        />
    <ImageView 
        android:layout_alignParentLeft="true"
        android:text="title"
        />
</RelativeLayout>

Of course, you'll need to set the layout width, height, ... on those elements.

Vincent Mimoun-Prat
  • 28,208
  • 16
  • 81
  • 124
  • Great! That worked perfect when setting layout_width="fill_parent" and layout_height="wrap_content" for both TextViews. The only thing now is that the ImageView and the image inside is positioned in the top left corner I want it to be centered vertically, how is that possible? – Martin Apr 04 '11 at 16:29
  • Check the RelativeLayout documentation, you'll find all the properties you need. In particular, one is named something like layout_centerVertical – Vincent Mimoun-Prat Apr 05 '11 at 08:24
0

I think that you'll find the answer here: set the absolute position of a view in Android

Community
  • 1
  • 1
Brian Driscoll
  • 19,373
  • 3
  • 46
  • 65