I'm having trouble placing an AdMob banner in settings. I have managed to place it in the first screen by using the following layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/MainLinearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" android:baselineAligned="false">
<fragment
android:id="@+id/admob"
android:name="ro.infiniteloop.phonehancer.AdmobFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<fragment
android:id="@+id/settings"
android:name="ro.infiniteloop.phonehancer.SettingsFragment"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
</LinearLayout>
The AdmobFragment layout being:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/AdmobLinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
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="ro.infiniteloop.phonehancer.AdmobFragment" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-5599997006266549/8381977716" />
</LinearLayout>
And the settings fragment layout:
<PreferenceCategory
android:key="pref_key_storage_settings"
android:title="@string/pref_sms_storage_title" >
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_key_auto_delete"
android:summary="@string/pref_summary_auto_delete"
android:title="@string/pref_title_auto_delete" />
.....
All good so far. But when I go inside a child preference screen the original layout is reset and the ad is no longer displayed
An image of the child preference screen
Is there a way to lay these elements inside a layout or to write some custom code that keeps the ad on all preference child screens?