I'm using a custom layout to display preferences so that I can insert an ad banner at the bottom of the screen. The idea is to have the banner stick to the bottom of the page, and have the preferences displayed in the rest of the screen in a scrollview. I have a problem with the height taken by the preferences. I've currently hardcoded it to "2000dip" in the XML layout below.
It works fine, the banner stays at the bottom, preferences at the top in a scrollable view.
But having a hardcoded height value is bad and I'd like it to automatically being set to the exact height taken by the preferences because currently it is either too short or too long (with a blank area after the preferences). I've tried to replace the hardcoded value with wrap_content or fill_parent with no success. Any idea?
In my PreferenceActivity I've included the following two lines:
setContentView(R.layout.preferences_scrollable);
addPreferencesFromResource(R.layout.preferences);
And I've defined a layout preferences_scrollable in the xml file preferences_scrollable.xml:
<?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:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:id="@+id/pref_scrollable_sv">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:id="@+id/pref_scrollable_ll">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_height="2000dip">
</ListView>
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<com.google.ads.AdView android:id="@+id/ad"
ads:adSize="BANNER" android:layout_width="fill_parent"
ads:loadAdOnCreate="true" ads:adUnitId="xxx"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</LinearLayout>