【问题标题】:AdWhirl eats up all space of listviewAdWhirl 占用了列表视图的所有空间
【发布时间】:2010-12-11 14:55:11
【问题描述】:

我有一个包含图像、按钮、列表视图和 adwhirllayout 的垂直线性布局的 Activity。所有人都具有高度 wrap_content 并且列表视图具有 weight="1" 以强制它使用所有剩余空间。只要 adwhirl 不显示广告,它就可以正常工作。一旦完成,线性布局将重绘,列表视图的高度变为 0!当列表视图显示项目时也是如此。这些消失。 adwhirl 和剩下的一样大有人知道怎么了?

【问题讨论】:

    标签: android listview android-linearlayout adwhirl


    【解决方案1】:

    这是我的应用程序中的列表视图之一。它还在屏幕底部有 admob。试一试。

    <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>
    

    【讨论】:

    • 您明确将高度限制为 48dip。如果我这样做,它会起作用,但我不确定 adwhirl 广告的大小和 48dip 是否始终相同。他们的示例代码使用了 wrap_content。
    • 另外一个缺点是如果没有广告,空间是不会释放的
    • 是的。但我想你不能一边吃蛋糕一边吃。至少我还没有想出办法做到这一点。 ;)
    猜你喜欢
    • 2019-03-11
    • 2015-03-24
    • 2020-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多