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!
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.
replace this :
android:layout_width="fill_parent"
by
android:layout_width="wrap_content"
Use relativeLayout and place each child side by side using id's
Example:
<RelativeLayout .... >
<TextView
android:id="+@id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter text here:"
/>
<EditText
android:id="+@id/edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/text"
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.