android - Scrollview autoscrolls after changing visibility of Ad -


i have scrollview contains textview, imageview, webview , sticky publisheradview @ bottom of relativelayout contains scrollview , publisheradview.

my ad's visibility gone default, after ad loads, change visibility of publisheradview visible.

problem when change visibility, scrollview auto scrolls location, , don't want that.

how can fix this?

this 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="fill_parent" android:background="@color/windowbackground">  <linearlayout     android:layout_above="@+id/ad_view_sticky"     android:layout_width="match_parent"     android:layout_height="fill_parent"     android:background="@color/windowbackground"     android:orientation="vertical">     <linearlayout         android:id="@+id/container_toolbar"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:orientation="vertical">          <include             android:id="@+id/toolbar"             layout="@layout/toolbar" />     </linearlayout>     <scrollview         android:id="@+id/scroller"         android:layout_width="match_parent"         android:layout_height="0dp"         android:layout_weight="1">          <linearlayout             android:id="@+id/news_content"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:background="@color/windowbackground"             android:orientation="vertical" >              <textview                 android:id="@+id/title"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:textcolor="@color/main_text_color"                 android:textsize="24sp"                 android:textstyle="bold"                 android:layout_marginleft="10dp"                 android:layout_margintop="5dp"                 android:layout_marginright="10dp"                 android:layout_marginbottom="5dp" />              <textview                 android:id="@+id/spot"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:textcolor="@color/main_text_color"                 android:layout_marginbottom="5dp"                 android:textsize="16sp"                 android:textstyle="bold"                 android:layout_marginleft="10dp"                 android:layout_margintop="5dp"                 android:layout_marginright="10dp" />              <relativelayout                 android:layout_width="wrap_content"                 android:layout_height="wrap_content"                 android:id="@+id/relativelayout">                   <progressbar                     android:id="@+id/progressbar"                     style="?android:attr/progressbarstyle"                     android:layout_width="wrap_content"                     android:layout_height="wrap_content"                     android:layout_gravity="center"                     android:visibility="visible"                     android:layout_centerhorizontal="true"                     android:layout_centervertical="true"                     android:layout_margintop="40dp"                     android:layout_marginbottom="40dp"/>                  <imageview                     android:id="@+id/image"                     android:layout_width="fill_parent"                     android:layout_height="wrap_content"                     android:contentdescription="@string/descr_image"                     android:src="@drawable/resimsiz"/>                   <linearlayout                     android:layout_width="fill_parent"                     android:layout_height="wrap_content"                     android:orientation="horizontal"                     android:layout_alignparentbottom="true"                     android:background="#80000000">                      <textview                         android:id="@+id/category"                         android:layout_width="0dp"                         android:layout_height="wrap_content"                         android:layout_weight="1"                         android:textcolor="@color/secondary_text_color"                         android:textsize="14sp"                         android:textstyle="bold"                         android:layout_marginstart="3dp"                         android:layout_marginleft="3dp"                         android:layout_marginbottom="3dp"                         android:layout_margintop="3dp" />                      <textview                         android:id="@+id/date"                         android:layout_width="0dp"                         android:layout_height="wrap_content"                         android:layout_weight="1"                         android:gravity="end"                         android:textcolor="@color/secondary_text_color"                         android:textsize="14sp"                         android:textstyle="bold"                         android:layout_marginend="3dp"                         android:layout_marginright="3dp"                         android:layout_marginbottom="3dp"                         android:layout_margintop="3dp" />                 </linearlayout>              </relativelayout>              <com.google.android.gms.ads.doubleclick.publisheradview                 xmlns:ads="http://schemas.android.com/apk/res-auto"                 android:id="@+id/ad_view"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 ads:adsize="smart_banner"                 ads:adunitid="@string/ad_news_detail_sticky"                 android:layout_margintop="10dp"                 android:layout_marginbottom="5dp"                 android:visibility="gone"/>              <webview                 android:id="@+id/content"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 tools:ignore="webviewlayout"                 android:layout_marginleft="10dp"                 android:layout_marginright="10dp"                 android:layout_margintop="5dp"/>             <textview                 android:id="@+id/tv_related_contents"                 android:layout_width="match_parent"                 android:layout_height="wrap_content"                 android:text="@string/tv_related_contents"                 android:visibility="gone"                 android:padding="10dp"                 android:textsize="16sp" />         </linearlayout>     </scrollview> </linearlayout>  <com.google.android.gms.ads.doubleclick.publisheradview     xmlns:ads="http://schemas.android.com/apk/res-auto"     android:id="@id/ad_view_sticky"     android:layout_alignparentbottom="true"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     ads:adsize="smart_banner"     ads:adunitid="@string/ad_news_detail_sticky"     android:layout_margintop="10dp"     android:layout_marginbottom="5dp"     android:layout_centerinparent="true"     android:visibility="gone"/> </relativelayout> 

and code part is

madview.setadlistener(new adlistener(){ publisheradview madview = (publisheradview) findviewbyid(r.id.ad_view_sticky);     @override     public void onadloaded() {         super.onadloaded();         madview.setvisibility(view.visible);     } }); 

actually adding android:descendantfocusability="blocksdescendants" root relativelayout solved problem helps


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -