Android Forums

Go Back   Android Forums > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
Reply
 
LinkBack Thread Tools Display Modes
Old 11-01-2009, 08:40 PM   #1
Junior Member
 
Join Date: Sep 2009
Posts: 1
Friends: 0
View rvaul's Profile   View rvaul's Photo Album   View rvaul's Blog   View Social Groups
So I'm trying to create a simple "point-and-click-change-image" style app. I made my own custom buttons, and the only problem I'm having is with the layout of the buttons. I would like the "left" button in the upper left hand corner, and the "right" button in the upper right hand corner.

Now, putting each of my buttons in it's own layout seems to make the buttons "disappear", and adding any weight or gravity to either of them seems to stretch them WAY out, even if I change the width from "wrap_content" over to "40px", (the width of the button).

This is my XML layout from one of the screens. (I know this is wrong, but I can't find the right way either )


<?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">

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

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

</LinearLayout>




Thank you for any help.
rvaul is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Old 11-27-2009, 02:14 AM   #2
Junior Member
 
Join Date: Nov 2009
Posts: 2
Friends: 0
View Gnostus's Profile   View Gnostus's Photo Album   View Gnostus's Blog   View Social Groups
Try using a relative or other layout, linear always gives me problems with parenting the spacing on build. can be frustrated, I use relative layout and all it well and easier managed.
Gnostus is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Old 11-28-2009, 11:07 AM   #3
Junior Member
 
Join Date: Nov 2009
Posts: 3
Friends: 0
View appforce.org's Profile   View appforce.org's Photo Album   View appforce.org's Blog   View Social Groups
Hi,

You should change the LinearLayout with RelativeLayout and add attribute android:layout_alignParentRight="true" to the right button

appforce.org
appforce.org is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Reply

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error inflating xml layout file pierpa Android Development, Answers, Tutorials, and Code Snippets 3 08-01-2010 12:36 AM
Layout Tutorial Bug: You must supply a layout_width attribute. chipolata Android Development, Answers, Tutorials, and Code Snippets 1 11-01-2009 09:08 PM
Exchange sync on Hero - folder layout issues Spacemonkey Android Chat 3 09-24-2009 06:31 AM
G1 Camera button HALP misspriss G1 6 05-11-2009 08:50 PM
How to set the layout from java code? liviu1988 Android Development, Answers, Tutorials, and Code Snippets 0 03-26-2009 07:28 AM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 10:04 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2008 TalkAndroid.com. All rights reserved.