Results 1 to 2 of 2
Thread: Layout problems
- 02-14-2012, 12:17 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 11
- Rep Power
- 0
Layout problems
I want to display the following:
TextView
EditView
2 x Button
TextView
This is the code I have:
The last TextView doesn't show up. Any ideas why?Java Code:<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Type here:"/> <EditText android:id="@+id/entry" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:drawable/editbox_background" android:layout_below="@id/label"/> <Button android:id="@+id/ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/entry" android:layout_alignParentRight="true" android:layout_marginLeft="10dip" android:text="OK" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/ok" android:layout_alignTop="@id/ok" android:text="Cancel" /> <TextView android:id="@+id/message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello" /> </RelativeLayout>
- 02-19-2012, 09:23 PM #2
Re: Layout problems
So you want a layout like this? Don't mind the title :P

Well that was all using LinearLayouts and it was very easy. The root layout is a LinearLayout (horizontal) and the next two down are LinearLayouts (Vertical) with some padding and weights added. Then the last item is your TextView. You can customize it anyway you want but you don't have to use Relative Layouts all the time.
Java Code:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/linearLayout3" android:layout_width="match_parent" android:layout_height="wrap_content" android:baselineAligned="false" > <TextView android:id="@+id/label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_marginRight="10dp" android:text="Type here:" /> <EditText android:id="@+id/entry" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:drawable/editbox_background" > </EditText> </LinearLayout> <LinearLayout android:id="@+id/linearLayout2" android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="OK" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Cancel" /> </LinearLayout> <TextView android:id="@+id/message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout>Last edited by Kyle227; 02-19-2012 at 09:38 PM.
Similar Threads
-
GUI Layout problems.
By Vampiricx3 in forum AWT / SwingReplies: 1Last Post: 02-04-2012, 04:52 AM -
JAVA GUI Layout problems...
By arcelivez in forum AWT / SwingReplies: 1Last Post: 11-25-2011, 01:48 AM -
Package layout problems trying to make a new Swing component.
By TheShagg in forum AWT / SwingReplies: 13Last Post: 12-06-2010, 05:57 AM -
Keyboard Layout Problems
By FrederikNS in forum EclipseReplies: 0Last Post: 10-28-2008, 04:03 PM -
JPanel / layout problems
By Warhorsei in forum AWT / SwingReplies: 4Last Post: 06-04-2008, 05:26 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks