在屏幕底部设置列表视图后的admob标语

问题描述 投票:0回答:6

我有一个显示列表视图的xml布局。我还想在此列表视图的下面显示一个admob横幅,并且无论用户滚动列表视图如何,我都希望始终在底部显示它。我有这个xml布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
<LinearLayout android:layout_width="fill_parent"
              android:id="@+id/home_layout"
              android:orientation="vertical"
              android:layout_height="wrap_content">
    <!-- Put all your application views here, such as buttons, textviews, edittexts and so on -->
    <ListView
    android:id="@+id/lvImages"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"     
    android:dividerHeight="1dp" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent"
            android:orientation="horizontal"
              android:id="@+id/footerLayout"
              android:layout_height="wrap_content"
              android:gravity="bottom"
              android:layout_centerHorizontal="true"
              android:layout_alignParentBottom="true"
              android:layout_alignBottom="@+id/home_layout">

</LinearLayout>

而且我在onCreate方法中创建了Admob标语:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listado_imagenes_subidas_main);

    // Crear adView.
    adView = new AdView(this);
    adView.setAdUnitId("XXXXXXXXXXXXXXXXXXX");
    adView.setAdSize(AdSize.BANNER);

    LinearLayout layout = (LinearLayout)findViewById(R.id.footerLayout);
    layout.addView(adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

    // load list application
    listImagenes = (ListView)findViewById(R.id.lvImages);

    // create new adapter
    ImagenesAdapter adapter = new ImagenesAdapter(this, ListadoImagenes());
    // set adapter to list view
    listImagenes.setAdapter(adapter);
}

如何在列表视图下面显示粘性页脚区域?

谢谢你。

android android-listview admob sticky-footer
6个回答
3
投票

您需要稍微修改一下布局。


1
投票

尝试一下,调整两个子线性布局中的android:layout_weight=""以获得您喜欢的高度。


0
投票

这样做吧。


0
投票

尝试一下:-


0
投票
*

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
    <LinearLayout android:layout_width="fill_parent"
                  android:id="@+id/home_layout"
                  android:orientation="vertical"
                  android:layout_height="wrap_content">
        <!-- Put all your application views here, such as buttons, textviews, edittexts and so on -->
        <ListView
        android:id="@+id/lvImages"
        android:layout_width="match_parent"
        android:layout_height="0dip"    
        android:layout_weight="1" 
        android:dividerHeight="1dp" />

    <LinearLayout android:layout_width="match_parent"
                android:orientation="horizontal"
                  android:id="@+id/footerLayout"
                  android:layout_height="wrap_content"
                  android:gravity="bottom"
                 >

    </LinearLayout>
</LinearLayout>

0
投票

添加此android:layout_centerHorizo​​ntal =“ true”android:layout_alignParentBottom =“ true”

© www.soinside.com 2019 - 2024. All rights reserved.