6

I have an activity that contain RecycleView with maximum 30 items. Every item contains 2 to 3 text views and 1 button. I have animation on clicking the button.

Before adding admob banner, the performance was really good, scrolling was smooth.

After adding admob banner, the scroll is cutting, clicking the button take a bit to respond. Aditionally, i see message shows me that Too many work on main thread!

Is there any suggestion about how to fix it ? Or what can help making it better ? How can I get smooth scrolling with admob banner enabled?

Hopefully I am not the only one facing this problem!

UPDATE:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:paddingTop="30dp"
        android:paddingBottom="64dp"
        android:clipToPadding="false"
        android:id="@+id/rv_Test"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />


    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center|bottom"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id" />

</RelativeLayout>
MBH
  • 16,271
  • 19
  • 99
  • 149
  • We need a little more explanation I think. Where is the admob banner located? is it in a separate view? for example, ..... ? – Saehun Sean Oh Dec 14 '15 at 22:25
  • Can you post where you banner is located? You are calling this banner in your adapter view? Post your adapter code and the part you are calling the banner. – diogojme Dec 15 '15 at 19:41
  • @SaehunSeanOh this is the layout – MBH Dec 15 '15 at 20:01
  • I think is nothing relationed with the banner, i think you are doing heavy process in your onBindViewHolder and may your animation is too heavy to run in the `Main Thread` when you click in the button. Consider put it in a `Separated Thread`, like `Runnable` , check this answer http://stackoverflow.com/q/11123621/1879661 – diogojme Dec 15 '15 at 20:14
  • @diogojme animation can be done out of main thread ? – MBH Dec 15 '15 at 20:39

2 Answers2

3

It Seams that adView is the problem than I have replaced the adView with NativeContentAdView to use the Native Ads

Now the scroll is smooth

This is the link of the doc https://developers.google.com/admob/android/native

Davide
  • 3,407
  • 1
  • 20
  • 22
0

Admob takes some time to load the ads in start so load ads with some delay after activity transition animation is completed :

Handler handler = new Handler ();
handler.postDelayed (new Runnable () {
 @Override
 public void run () {
      AdRequest bannerRequest = new AdRequest.Builder (). Build ();
      mAdView.loadAd (bannerRequest);
 }
}, 2000);
Sourav Rana
  • 141
  • 1
  • 2