Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob AdView causing ScrollView to scroll when shown [duplicate]

I have the following XML layout

<RelativeLayout>
   <ScrollView>
   </ScrollView>
   <LinearLayout>
   </LinearLayout>
</RelativeLayout>

Into the LinearLayout I am adding an admob AdView through code. The ScrollView contains content and displaying it before the AdView getting intialized.

The problem is, when the Ad gets shown the ScrollView scrolls down in the size (height) of the Ad.. I am guessing that because the ScrollView is set to height=match_parent and above=LinearLayout, when the ad initialized the ScrollView gets resized and that is what causing the scroll (LinearLayout is set to align to parent bottom).

Is there any way to get around it? I want the ScrollView to stay in the same scroll offset that it was on before the ad got to shown on the screen.

like image 695
Idan Avatar asked Nov 10 '13 08:11

Idan


1 Answers

Add android:descendantFocusability="blocksDescendants" to the immediate child of Scrollview. It'll solve the problem.

like image 126
M.Prabha karan Avatar answered Sep 23 '22 21:09

M.Prabha karan