Reputation: 807
My layout is like this:
<ScrollView
android:id="@+id/scrollView_page1"
android:layout_width="300dp"
android:layout_height="700dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="60dip"
android:gravity="right"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/string1"
android:id="@+id/textview1"/>
<EditText
android:id="@+id/edittext1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="200dp"
android:inputType="number"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="60dip"
android:gravity="right"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/string2"
android:id="@+id/textview2"/>
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinner1"
android:width="200dp"
/>
.........
The distance between TableRows seems not so regular: some of them are too close and some of them are too far. I don't want to use android:paddingTop adjust them one by one.
is there any easy way to make same distance between them? Currently it looks like this:
Upvotes: 1
Views: 2310
Reputation: 6084
@giga_abhi is spot on, but I would add that in each TableRow, you also need:
android:layout_height="0dip"
and in the LinearLayout
:
android:layout_height="fill_parent"
and in the ScrollView
:
android:fillViewport="true"
Upvotes: 3
Reputation: 1126
In the LinearLayout
set:
android:weightSum="(no of tables say 3)"`
and in each TableRow
add this line:
android:layout_weight="1"`
This will form TableRow with same height as your orientation is Vertical. The only part remains is adjusting height of elements inside TableRow.
Upvotes: 1