Android Programming Tutorials

(Romina) #1
A Fancier Form

<TextView android:text="Address:" />
<EditText android:id="@+id/addr" />
</TableRow>
<Button android:id="@+id/save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save"
/>
</TableLayout>

Notice that we replaced the three LinearLayout containers with a


TableLayout and two TableRow containers. We also set up the EditText


column to be stretchable.


Recompile and reinstall the application, then run it in the emulator. You


should see something like this:


Figure 7. Using a TableLayout

Notice how the two EditText fields line up, whereas before, they appeared


immediately after each label.


20
Free download pdf