Question

I want to display on the top of activity which consist of scrollable tableview. The content and number of rows are dynamic in tableview.

when I try to run the below code, It shows me table until when the ad is loaded, but when the ad is loaded the tableview disappears. I dont understand why this is happening.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/linearLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="***********"
        ads:loadAdOnCreate="true" />

    <ScrollView
        android:id="@+id/scroll1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TableLayout
            android:id="@+id/table_layout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <TableRow>

                <TextView
                    android:id="@+id/left_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0"
                    android:gravity="left|center_vertical"
                    android:padding="5dip"
                    android:text="Code" />

                <TextView
                    android:id="@+id/middle_text"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="right|center_vertical"
                    android:padding="5dip"
                    android:text="Name of Company" />

                <TextView
                    android:id="@+id/right_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0"
                    android:gravity="right|center_vertical"
                    android:padding="5dip"
                    android:text="1.3" />
            </TableRow>
        </TableLayout>
    </ScrollView>

</LinearLayout>
Was it helpful?

Solution

The default orientation of LinearLayout is horizontal. When ads is loaded, all contents shifts to the right. You should set orientation of the LinearLayout to vertical. Add this to your LinearLayout:

android:orientation="vertical"

OTHER TIPS

Yout tablelayout width is fillparent. Change it to wrap content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top