How can I make a tablelayout scroll horizontally and vertically? The columns of this tablelayout are generated dynamically. At this moment he is only sliding vertically.
In some situations the information contained in the tablelayout line will be too large and you will need to slide horizontally to view it completely.
Here is my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/activity_linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizon`enter code here`tal" >
<Spinner
android:id="@+id/activity_spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="start"
android:drawSelectorOnTop="true"
style="@android:style/Widget.Holo.Light.Spinner" />
<EditText
android:id="@+id/activity_edt1"
android:labelFor="@+id/consultaCliente_edt1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="text"
style="@style/EditText" >
</EditText>
<ImageView
android:id="@+id/activity_bt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/bt1"
android:src="@drawable/search" />
</LinearLayout>
<LinearLayout
android:id="@+id/activity_linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:orientation="horizontal" >
<Spinner
android:id="@+id/activity_spinner2"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="start"
android:drawSelectorOnTop="true"
style="@android:style/Widget.Holo.Light.Spinner" />
</LinearLayout>
<LinearLayout
android:id="@+id/activity_linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start"
android:orientation="horizontal" >
<Spinner
android:id="@+id/activity_spinner3"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="start|bottom"
android:drawSelectorOnTop="true"
style="@android:style/Widget.Holo.Light.Spinner" />
<ImageView
android:id="@+id/activity_bt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:layout_gravity="end"
android:contentDescription="@string/bt2"
android:src="@drawable/information" />
</LinearLayout>
<ScrollView
android:id="@+id/activity_scrollView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<TableLayout
android:id="@+id/activity_tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:shrinkColumns="*"
android:stretchColumns="*" >
</TableLayout>
</ScrollView>
<LinearLayout
android:id="@+id/activity_linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:background="@color/orange"
android:baselineAligned="false"
android:orientation="horizontal" >
<TextView
android:id="@+id/activity_txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="0sp"
android:paddingEnd="10sp"
android:text="@string/txt1"
style="@style/TextViewBlack" />
</LinearLayout>
</LinearLayout>
Solved!
<ScrollView
android:id="@+id/activity_scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:scrollbars="horizontal|vertical"
android:scrollbarStyle="outsideInset"
android:fillViewport="true">
<HorizontalScrollView
android:id="@+id/activity_horizontalView1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:scrollbars="horizontal|vertical">
<TableLayout
android:id="@+id/activity_tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
</TableLayout>
</HorizontalScrollView>
</ScrollView>