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

Apps Layouts and blank space

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.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones