В моем приложении есть 4 Buttons
на главном экране, и каждая кнопка открывает новый Activity
. Каждый Activity
содержит Fragment
и в конце Fragment
находится Admob
баннер. Принципиальное расположение каждого Fragment
, как: Admob AdBanner загрузка вызывает фрагмент для деформирования
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
//some stuff here
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adViewEncodeManual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_bottom_home_screen_banner">
</com.google.android.gms.ads.AdView>
HomescreenActivity
использует TableLayout
вместо linearLayout
. Я загружаю добавление по onActivityCreated
внутри каждого Fragment
.
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
if(localAdView == null)
{ // if prevents a loadRequest again when activity is resumed
localAdView = (AdView) getActivity().findViewById(R.id.adViewHome);
AdRequest adRequest = new AdRequest.Builder().addTestDevice("F0554446AEA73E5599774C945E9B99F1").build();
localAdView.loadAd(adRequest);
}
}
Баннеров LoadUp штрафа на каждый Activity
, но если я снова и снова переключиться с 1 Activity
к другому я получить искаженное отображение со случайными сломанными View
с. Он фиксируется, когда я нажимаю любой.
Проблема с баннерами только потому, что когда я выключаю интернет, все в порядке.
Любые советы ребята?
Table_layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context="com.apps.toffeesoft.easyqrReader.HomeScreenActivityFragment">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/adViewHome"
android:layout_height="wrap_content">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/home_background"
>
<TableRow
>
<Button
android:id="@+id/btnScan"
android:elevation="@dimen/abc_control_corner_material"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_marginBottom="-6dp"
android:layout_marginRight="-7dp"
android:layout_height="wrap_content"
android:text="@string/home_scan_heading"
android:drawableTop="@drawable/ic_image_camera_alt" />
<Button
android:id="@+id/btnCreate"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_marginBottom="-6dp"
android:layout_height="wrap_content"
android:text="@string/home_create_plain_heading"
android:drawableTop="@drawable/create_qr_plain"
/>
</TableRow>
<TableRow
android:layout_width="match_parent">
<Button
android:id="@+id/btnCreateContact"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_marginRight="-7dp"
android:layout_marginTop="-6dp"
android:layout_height="wrap_content"
android:text="@string/home_create_contact_qr_heading"
android:drawableTop="@drawable/contact_image"
/>
<Button
android:id="@+id/btnQrHistory"
android:layout_weight="0.5"
android:layout_width="0dp"
android:layout_marginTop="-6dp"
android:layout_height="wrap_content"
android:text="@string/qr_history"
android:drawableTop="@drawable/history"
/>
</TableRow>
</TableLayout>
</LinearLayout>
<!--
<com.google.android.gms.ads.AdView
android:id="@+id/adViewHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_bottom_home_screen_banner">
</com.google.android.gms.ads.AdView>
-->
</RelativeLayout>
Elltz, спасибо за ваше предложение. Я попробовал оба ваших предложения, но тот же результат :(Я даже попытался помещать рекламный баннер внутри макета деятельности вместо макета фрагмента, но опять же тот же результат. Я также изменил layout_height на wrap_parent, но без эффекта. – Vikram
вы можете опубликовать рис. выглядит @ Vikram я буду голосовать за вас, так что вы получите достаточно rep – Elltz
я все еще не могу добавить изображения. Я загрузил его по этой ссылке http://tinypic.com/view.php?pic=xf4x2s&s=8#.VVEwudqqqko – Vikram