-1
Я пытаюсь добавить баннер AdMob в одном из моих приложений для Android. Я пробовал много вещей, но я не могу показать в нижней части моего макета. Я прикрепил код от своей деятельности. Пожалуйста, проверьте и сообщите мне, что с ним не так.Объявление Проблема с размещением Android
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_layout_background_color"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize">
</android.support.v7.widget.Toolbar>
<GridView
android:id="@+id/lv_Levels"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@android:color/transparent"
android:horizontalSpacing="20dp"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="20dp">
</GridView>
<LinearLayout
android:id="@+id/ad"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/main_layout_background_color"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="horizontal">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
Я не могу держать это дно. его выход из экрана, и поэтому его не показывают.
Благодаря
Используйте относительное расположение в качестве основного контейнера (текущий Linear Layout) и использовать андроид: layout_alignParentBottom = "истина" на вашем Линейная компоновка с @ + id/ad. Это приведет к добавлению баннера в нижней части экрана. –
@NileshSingh Теперь он показывает мои объявления в порядке, но мой gridview будет срезаться в первой и последней строке. – Priya
Да, это произойдет, если вы держите липкий баннер внизу. Убедитесь, что вы используете android: layout_above = "@ + id/ad" в своем GridView. Это решит проблему с нижним баннером. Используйте аналогичный подход и для верхней части. –