Jeremy Henderson Jeremy Henderson - 1 month ago 14
Android Question

Adview displaying on top of soft keyboard

I have just integrated AdWhirl into my app. I have the AdWhirl view set to show up on the bottom of the layout of my main activity. I have a few EditText boxes on my main layout and when the app first launches clicking the text boxes displays the soft keyboard normally. However when I go to another activity and back to my main activity, then click the EditText the soft keyboard pops up with the AdWhirl view on top, covering my EditText box. I have been struggling with this for days. Any help would be appreciated.

I have android:windowSoftInputMode="adjustPan" defined in my manifest for all activities.

Here is my main.xml layout:

<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView android:id="@+id/ImageView02"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/other_bg_small" android:layout_weight="1"/>

<ImageView android:id="@+id/ImageView01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:background="@drawable/banner" android:layout_alignParentTop="true"
android:paddingBottom="30dip"/>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:stretchColumns="1" android:gravity="center" android:id="@+id/table01"
android:layout_below="@id/ImageView01" >

... Table stuff
</TableLayout>

<LinearLayout android:layout_width="fill_parent"
android:id="@+id/ad_layout" android:layout_height="wrap_content"
android:gravity="bottom" android:layout_alignParentBottom="true"
android:layout_alignBottom="@+id/RelativeLayout01" android:layout_weight="1">

<com.adwhirl.AdWhirlLayout android:id="@+id/adwhirl_layout"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>

</LinearLayout>

</RelativeLayout>

Joe Joe
Answer

Try setting a onFocusChangeListener to your EditText boxes. When they get focus, set the AdWhirl view visibility to View.INVISIBLE so it doesn't obstruct the textboxes and then set it back to visible once focus is lost.

final AdWhirl ad = (AdWhirl)findViewById(R.id.adwhirlAd);
        EditText et = (EditText)findViewById(R.id.editTextBox);
        et.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {

                ad.setVisibility(hasFocus ? View.INVISIBLE : View.VISIBLE);

            }
        });