Java 使用Google Admob自动滚动片段和活动?
我正在制作我的第一个android应用程序,它几乎完成了。所以今天我在其中添加了google admob。但现在添加admob后,我的应用程序面临问题 一、 在我的android应用程序顶部添加横幅。现在的问题是,我在我的应用程序底部,应用程序顶部的横幅广告被加载。加载add后,我的应用程序会自动位于顶部 同一问题的另一种类型 我在片段A上。在片段A上有一个横幅附加。从片段A开始,我在片段B上。现在,当我回到片段A时,我不在我离开片段A的位置 在我的整个项目中没有admob的java代码 所有这些类型的问题都是在应用admob之后开始出现的。如果我禁用addmob代码,我的应用程序工作正常。没有自动滚动的问题。或者当我从片段B回到片段A时,我来到我离开片段A的位置。在禁用admob之后 所以我认为这个问题是因为admob。因为我清楚地在我的应用程序中应用了fragment的堆栈维护Java 使用Google Admob自动滚动片段和活动?,java,android,android-fragments,android-activity,admob,Java,Android,Android Fragments,Android Activity,Admob,我正在制作我的第一个android应用程序,它几乎完成了。所以今天我在其中添加了google admob。但现在添加admob后,我的应用程序面临问题 一、 在我的android应用程序顶部添加横幅。现在的问题是,我在我的应用程序底部,应用程序顶部的横幅广告被加载。加载add后,我的应用程序会自动位于顶部 同一问题的另一种类型 我在片段A上。在片段A上有一个横幅附加。从片段A开始,我在片段B上。现在,当我回到片段A时,我不在我离开片段A的位置 在我的整个项目中没有admob的java代码 所有这
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:fitsSystemWindows="true"
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="3dp"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/bannerSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:layout_marginTop="3dp" />
<include
layout="@layout/header_just_in"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/justInRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/featuredDealRecyclerView"
android:layout_marginTop="3dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/BannerAdUnit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginTop="3dp"
android:layout_marginBottom="6dp"
ads:adSize="SMART_BANNER"
android:descendantFocusability="blocksDescendants"
ads:adUnitId="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
</com.google.android.gms.ads.AdView>
<include
layout="@layout/header_exiting_offer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<include
layout="@layout/exciting_offer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp" />
<include
android:id="@+id/xyz"
layout="@layout/header_featured_deal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/featuredDealRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/xyz"
android:layout_marginTop="3dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<include
layout="@layout/header_coupons_deals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/couponDeals_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/featuredDealRecyclerView"
android:layout_marginTop="3dp"
android:overScrollMode="never" />
<include
layout="@layout/header_loot_box_special"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<include
layout="@layout/loot_box_special_1"
android:id="@+id/lootBoxSpecials"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<include
layout="@layout/loot_box_special_2"
android:id="@+id/lootBoxSpecials"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<include
layout="@layout/group_deals"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lootBoxSpecials"
android:layout_marginTop="6dp" />
<include
android:id="@+id/include_header_earnings"
layout="@layout/header_earnings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/earnings_freebiesRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/include_header_earnings"
android:layout_marginTop="3dp"
android:overScrollMode="never" />
<include
android:id="@+id/headerPinnedpost"
layout="@layout/header_blog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/pinned_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/headerPinnedpost"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:overScrollMode="never" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/hfAdView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="6dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</ScrollView>
我希望我的应用程序在加载广告后不会自动滚动到顶部。或者当我转到另一个片段并再次回到前一个片段时,我将回到我离开该片段的状态。如果禁用admob,所有这些功能都会正常工作。admob工作时出现问题。尝试将其添加到线性布局中
android:descendantFocusability="blocksDescendants"
它阻止子元素接收焦点