我已将添加暴民横幅添加到我的活动中,并且它正在按预期运行。只是一件事是错误的,它没有显示在前面,而是显示在后台。我希望将其展示在前面,但我无法这样做。
这是我的XML文件:
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:clipChildren="false"
android:descendantFocusability="blocksDescendants"
android:gravity="bottom"
app:umanoClipPanel="false"
app:umanoOverlay="true"
app:umanoPanelHeight="@dimen/sliding_panel_height"
app:umanoShadowHeight="4dp"
tools:ignore="MissingPrefix">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:addStatesFromChildren="true"
android:visibility="visible"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"></com.google.android.gms.ads.AdView>
</RelativeLayout>
<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/wallpaper"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ProgressBar
android:id="@+id/progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|start"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/content_margin"
android:theme="@style/RippleStyleLight" />
</FrameLayout>
<RelativeLayout
android:id="@+id/bottom_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66000000"
android:clipToPadding="false"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/sliding_panel_height"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="@dimen/content_padding"
android:paddingEnd="@dimen/content_margin"
android:paddingLeft="@dimen/content_margin"
android:paddingRight="@dimen/content_margin"
android:paddingStart="@dimen/content_margin"
android:paddingTop="@dimen/content_padding">
<TextView
android:id="@+id/name"
fontPath="fonts/Font-Medium.ttf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/text_content_title" />
<TextView
android:id="@+id/author"
fontPath="fonts/Font-Regular.ttf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/text_content" />
</LinearLayout>
<ImageView
android:id="@+id/menu_preview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/content_margin"
android:theme="@style/RippleStyle" />
<ImageView
android:id="@+id/menu_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/content_margin"
android:theme="@style/RippleStyle"
android:visibility="gone" />
<ImageView
android:id="@+id/menu_apply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="@dimen/content_margin"
android:theme="@style/RippleStyle" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/top_bar"
android:clipToPadding="false" />
</RelativeLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
放置AdView
的位置无关紧要,它总是显示在后面而不是前面。
我正在尝试在关闭的墙纸屏幕上添加admbob横幅。
我在主动性前面添加了横幅,即 I am trying to add banner at the bottom of the wallpaper.
答案 0 :(得分:0)
此代码显示如何在活动中显示横幅。它对我有用
XML代码
@Scheduled(cron = "0 0 1 * * ?") // based on your business logic
public void scheduleTaskUsingCronExpression() {
// loop through user_product_updates table and construct "data"
// username is from your spring security username (principal.getName())
template.convertAndSendToUser(username, "/queue/products", data);
}
此代码添加到清单文件中
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_home_footer"
android:layout_height="wrap_content" />
**此代码添加到Java文件中**
<manifest>
<application>
<!-- AdMob App ID: ca-app-pub-XXXXXXXXXXXXXXXXXXXXXXXXX -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="[ADMOB_APP_ID]"/>
</application>