Admob AdView 导致 ScrollView 在显示 [重复] 时滚动

Admob AdView causing ScrollView to scroll when shown [duplicate]

提问人:Idan 提问时间:11/10/2013 更新时间:2/23/2018 访问量:6103

问:

我有以下XML布局

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

在LinearLayout中,我通过代码添加了admob AdView。 ScrollView 包含内容,并在 AdView 初始化之前显示它。

问题是,当广告显示时,ScrollView 会随着广告的大小(高度)向下滚动。 我猜是因为 ScrollView 设置为 height=match_parent 和 above=LinearLayout,所以当广告初始化时,ScrollView 会调整大小,这就是导致滚动的原因(LinearLayout 设置为与父底部对齐)。

有什么办法可以绕过它吗?我希望 ScrollView 保持在广告在屏幕上显示之前所处于的滚动偏移量。

android-layout admob android-scrollview

评论


答:

1赞 M.Prabha karan 2/23/2018 #1

添加到 的直接子级。它会解决问题。android:descendantFocusability="blocksDescendants"Scrollview