Absolute positioning in XML?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Absolute positioning in XML?

Postby lostgame » Thu Apr 02, 2009 9:44 pm

Alright, so I'm designing my first Android app for the company I work at. Followed a bunch of tutorials, got our API working with java, all is great. The backend works 100% but the UI is the most absolutely God-awful thing I have ever had to work with.

I have a *very* specific layout I need to follow but everything acts like it all wants to be relative. I need everything to be absolutely positioned. If I use rules like 'gravity' and 'layout_gravity' they either simply don't work or do not behave as expected. All I want to do is just specify x and y values for views using this XML syntax, but I can't find any documentation anywhere specifying how to do this.

Can somebody please lend a hand? I'm so frustrated and I really want to give android an 100% chance, but I'm having such a hard time. It just doesn't seem to have the awesome support and documentation behind it that the iPhone has. I hope this forum can prove me wrong. =)
lostgame
Junior Developer
Junior Developer
 
Posts: 18
Joined: Thu Apr 02, 2009 8:59 pm

Top

Postby lostgame » Fri Apr 03, 2009 2:21 pm

Bump? I can't find any documentation on this, guys :/
lostgame
Junior Developer
Junior Developer
 
Posts: 18
Joined: Thu Apr 02, 2009 8:59 pm

Postby xspotlivin » Mon Apr 06, 2009 2:33 am

You can use an AbsoluteLayout. Here's an example of me positioning a button and textview on top of a custom view:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="horizontal"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    >
  12.  
  13. <example.android.someactivity.CustomView
  14.  
  15.         android:id="@+id/clockview"
  16.  
  17.         android:layout_width="fill_parent"
  18.  
  19.         android:layout_height="fill_parent"
  20.  
  21.         />
  22.  
  23. <Button
  24.  
  25.         android:id="@+id/checkbox"
  26.  
  27.         android:layout_width="wrap_content"
  28.  
  29.         android:layout_height="wrap_content"
  30.  
  31.         android:layout_x="50px"
  32.  
  33.         android:layout_y="20px"
  34.  
  35.         android:background="@drawable/box_check"
  36.  
  37.         />
  38.  
  39. <TextView
  40.  
  41.         android:id="@+id/currenttime"
  42.  
  43.         android:layout_width="wrap_content"
  44.  
  45.         android:layout_height="wrap_content"
  46.  
  47.         android:layout_x="240px"
  48.  
  49.         android:layout_y="160px"
  50.  
  51.         />
  52.  
  53. </AbsoluteLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
xspotlivin
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Feb 26, 2009 8:15 am
Location: Cambridge, MA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 7 guests