Yet another rpoblem with button layout...

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

Yet another rpoblem with button layout...

Postby rvaul » Fri Nov 06, 2009 3:18 am

I'm sure this has been covered many times over, but I'm apparently a monkey and am still having problems with this. I'm creating a "Point-and-click" style app for some kids, and everything is cool except for the layout of my buttons. (These are custom buttons, they are 40px wide by 55px tall).

I would like one in the upper left hand corner of the screen, and the other in the upper right hand corner. Adding any gravity or weight seems to just strecth the buttons out to the point where you can't really tell what they are.

This is the XML file I've been working with, and I know it's not correct obviously, but I can't seem to figure out what is.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/pic1">

<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left">
<Button android:id="@+id/Button01"
android:background="@drawable/buttonleft"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>

<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right">
<Button android:id="@+id/Button02"
android:background="@drawable/buttonright"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>

</LinearLayout>


A big old fat "Thank you" ahead of time for any help anyone can give me.
rvaul
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Nov 04, 2009 11:25 am

Top

Postby rvaul » Fri Nov 06, 2009 5:05 am

And solved.

I had been goofing off with this for a couple weeks. A few minutes ago I realized that I have been using "layout_alignParent" the wrong way.
rvaul
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Nov 04, 2009 11:25 am

Postby rvaul » Fri Nov 06, 2009 5:22 am

Oh, that and changing out the <Linear> for <Relative>...

I forgot that part of my new found genius-ism.
rvaul
Junior Developer
Junior Developer
 
Posts: 18
Joined: Wed Nov 04, 2009 11:25 am

Postby I_Artist » Fri Nov 06, 2009 4:58 pm

Thanks for taking the time to post the solution. :)

Cheers!
The I_Artist

follow me on Twitter: @I_Artist
follow Android Development on Twitter: #androiddev

Show the world that you are an #androiddev, wear the badge http://www.twibbon.com/join/androiddev
User avatar
I_Artist
Developer
Developer
 
Posts: 33
Joined: Fri Oct 16, 2009 3:49 am
Location: St-Eustache, Quebec

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests