RelativeLayout and layout_below/above positioning.

Put your problem here if it does not fit any of the other categories.

RelativeLayout and layout_below/above positioning.

Postby manojo » Fri Mar 21, 2008 12:44 pm

Hello,

I am trying to experiment with Layouts in android, and tried to take a look at what this looked like : http://code.google.com/android/devel/ui/xml.html

I copied the code to my page, and tried to run it, after having removed the @drawable tags (because I didn't create any drawable object). I just get a screen with every object overlapped one on the other..

I also commented the restoreValues method, because I don't have any such method

What am I missing ?

Thanks,
Manojo
manojo
Freshman
Freshman
 
Posts: 4
Joined: Fri Mar 21, 2008 12:33 pm

Top

Postby Jesmiatka » Fri Mar 21, 2008 3:00 pm

This is for m3 version, you are possibly using m5 release of the SDK.
Use the following code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <!-- Demonstrates using a relative layout to create a form -->
  4.  
  5. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android
  6.  
  7.                android:layout_width="fill_parent"
  8.  
  9.                android:layout_height="wrap_content"
  10.  
  11.                android:background="@drawable/blue"
  12.  
  13.                android:padding="10px">
  14.  
  15.  
  16.  
  17.    <TextView android:id="@+id/label"
  18.  
  19.              android:layout_width="fill_parent"
  20.  
  21.              android:layout_height="wrap_content"
  22.  
  23.              android:text="Type here:"/>
  24.  
  25.  
  26.  
  27.    <EditText android:id="@+id/entry"
  28.  
  29.              android:layout_width="fill_parent"
  30.  
  31.              android:layout_height="wrap_content"
  32.  
  33.              android:background="@android:drawable/editbox_background"
  34.  
  35.              android:layout_below="@id/label"/>
  36.  
  37.  
  38.  
  39.    <Button android:id="@+id/ok"
  40.  
  41.            android:layout_width="wrap_content"
  42.  
  43.            android:layout_height="wrap_content"
  44.  
  45.            android:layout_below="@id/entry"
  46.  
  47.            android:layout_alignParentRight="true"
  48.  
  49.            android:layout_marginLeft="10px"
  50.  
  51.            android:text="OK" />
  52.  
  53.  
  54.  
  55.    <Button android:layout_width="wrap_content"
  56.  
  57.            android:layout_height="wrap_content"
  58.  
  59.            android:layout_toLeft="@id/ok"
  60.  
  61.            android:layout_alignTop="@id/ok"
  62.  
  63.            android:text="Cancel" />
  64.  
  65. </RelativeLayout>
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


since m5 the ID tag is changed to ANDROID:ID
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby manojo » Sat Mar 22, 2008 6:52 pm

Thanks a lot, it works a wonder :-)

Manojo
manojo
Freshman
Freshman
 
Posts: 4
Joined: Fri Mar 21, 2008 12:33 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 24 guests