• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Layouts and blank space

  • Thread starter Thread starter Deleted User
  • Start date Start date
D

Deleted User

Guest
Suppose my layout is centered horizontally and vertically. Suppose I have 2 text views. Suppose I want a space between these text views so one isn't directly on top of the other. How would I do this? Is there a special tag? Do I need to use a TableLayout to space everything out good?
 
Code:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_vertical|center_horizontal"
    >
    <TableRow
    	android:gravity="center">
    	<EditText
    		android:id="@+id/PasswordText"
    		android:password="true" 
			android:layout_height="wrap_content"
			android:layout_width="250px"
			android:layout_centerHorizontal="true"
			android:layout_below="@+id/PasswordLabel"
			android:singleLine="true"
		/>
	</TableRow>
	<TableRow
		android:gravity="center">
		<Button
			android:id="@+id/LoginButton"
			android:text="Log in"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:layout_centerHorizontal="true"
		/>
	</TableRow>
</TableLayout>

Why is the LoginButton 250px wide? Shouldn't it be as wide as "Log in" takes to fit on the button? I was under the impression android:layout_width was relative to the button itself and not the are of the layout it is contained in.
 
You should be able to set the padding to get it how you like.
Ah, excellent. I'll use the padding properties to space appropriately. Thank you.


My follow-up question still stands out of curiosity
 
I haven't used tables much, but in my experience it will make all the columns be the same width, so the button is the same width as the text above it.
 
Back
Top Bottom