I've an Activity with a vertical linearlayout containing images, buttons, listview and adwhirllayout. All have for their height wrap_content and the listview has weight="1" to force it to use all remaining space. This works fine as long as the adwhirl doesn't show an ad. Once it does, the linearlayout redraws and the listview's height becomes 0! Also when the listview is showing items. These disappear. The adwhirl is as big as the remainingSomeone an idea what's wrong?
Asked
Active
Viewed 466 times
1 Answers
0
This is one of the listviews from my app. It also has admob at the bottom of the screen. Give this a go.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
</ListView>
<TextView
android:id="@+id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/no_contacts"
android:padding="10dp"
android:textSize="16sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
<LinearLayout
android:id="@+id/now_playing_loading"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center" >
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
app:backgroundColor="#000000"
app:primaryTextColor="#FFFFFF"
app:secondaryTextColor="#CCCCCC" >
</com.admob.android.ads.AdView>
</LinearLayout>

Siddharth Lele
- 27,623
- 15
- 98
- 151
-
You explicitly limit the height to 48dip. If I do that, it works but I'm not sure adwhirl ads are always the same size and 48dip. Their example code uses wrap_content. – Tin Dec 11 '10 at 15:16
-
1Another disadvantage is that if there's no ad, the space is not released – Tin Dec 11 '10 at 15:18
-
True. But i suppose you cant have the cake and eat it too. At least I haven't figured out a way to do that yet. ;) – Siddharth Lele Dec 11 '10 at 15:29