bikash giri bikash giri -4 years ago 217
Android Question

Use of Table Layout inside scroll view

Hello i am new in android

I was trying to use scroll view and somewhere on internet i found this code

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="1">


This code works perfectly but i don't understand what is the use of
android:stretchColumns="1">
?.If I change
stretchColumns="1"
to
"3"
or any no I am not getting any changes in my
scroll view
.

Answer Source

TableLayout can specify certain columns as shrinkable or stretchable by calling setColumnShrinkable()(xml:android:shrinkColumns) or setColumnStretchable()(xml:android:stretchColumns).

If marked as shrinkable, the column width can be shrunk to fit the table into its parent object. If marked as stretchable, it can expand in width to fit any extra space.

The total width of the table is defined by its parent container. It is important to remember that a column can be both shrinkable and stretchable .

For details information you may visit

https://developer.android.com/reference/android/widget/TableLayout.html

check out this example

<TableLayout
android:shrinkColumns="2,3"
android:stretchColumns="1,3"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download