views:

140

answers:

2

As the title says, every time I put a TextView before an EditText element in a LinearLayout, the EditText does not show. When I don't, it does.

I've narrowed the problem down to the TextView's layout_width attribute. If I give it "wrap_content", it works, but doesn't "block" down, and it appears on the same line as the EditText.

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#FFFFFFFF"
  >

<TextView
    android:text="Test"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />


  <EditText 
            android:id="@+id/marketValLow"
            android:layout_width="fill_parent"
            android:layout_height="35px"
            android:singleLine="true"
            android:layout_marginLeft="5px"
            android:layout_marginRight="5px"
            android:layout_marginTop="5px" /> 


</LinearLayout>

Any ideas? Thanks!

+1  A: 

replace this :

 android:layout_width="fill_parent"

by

 android:layout_width="wrap_content"
Sephy
Exactly. That works, but I need the TextView to (for lack of a better term, I'll use HTML lingo) block so that the EditView drops down below it, regardless of its contents. Meaning, I don't want the TextView on the same line as the EditText.
Allen Gingrich
+1  A: 

It sounds like you're after a vertical orientation to have the TextView above the EditView. LinearLayout defaults to horizontal.

So add android:orientation="vertical" to your LinearLayout definition.

oli
You're the man! Thanks.
Allen Gingrich