Skip to content Skip to sidebar Skip to footer

Android Tablelayout Inside Scrollview

I want both the ScrollView TableLayout to have same height as the screen, but whyy table is taken only half of the screen, whereas ScrollView is taking full screen as intended. I

Solution 1:

add this line in your scrollview xml -->

     android:fillViewport="true"

This enables the child layout to to take full screen if it's layout_width & layout_height is match_parent/fill_parent. . In your case TableLayout will get the full size on using this line ..! enjoy...!

Solution 2:

Putting a linearlayout in between works but I don't know why setting some height to table view directly doesn't work.

<ScrollViewxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@android:color/black"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context=".EditEntry" ><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:background="@android:color/darker_gray" ><TableLayoutandroid:id="@+id/tableLayout1"android:layout_width="match_parent"android:layout_height="1000dp" ><TableRowandroid:id="@+id/tr3a"android:layout_width="wrap_content"android:layout_height="0dp"android:layout_weight="1"android:background="@color/col1"android:gravity="center_vertical"android:padding="2.5dp" ><TextViewandroid:id="@+id/lab_bookname"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/bookname" /><EditTextandroid:id="@+id/bookname"android:layout_width="wrap_content"android:layout_height="wrap_content"android:hint="@string/definputtext2" /></TableRow><TableRowandroid:id="@+id/tr3"android:layout_width="wrap_content"android:layout_height="0dp"android:layout_weight="1"android:background="@color/col2"android:gravity="center_vertical"android:padding="2.5dp" ><TextViewandroid:id="@+id/lab_printname"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/print_name" /><EditTextandroid:id="@+id/printname"android:layout_width="wrap_content"android:layout_height="wrap_content"android:hint="@string/definputtext2" /></TableRow></TableLayout></LinearLayout></ScrollView>

Post a Comment for "Android Tablelayout Inside Scrollview"