简体   繁体   English

具有 100% 屏幕宽度和自定义 (90dp) 高度的 Admob 广告

[英]Admob ad with 100% screen width and custom(90dp) height

Im trying to display an admob ad which completely covers the width of screen (like SMART_BANNER), and 90dp constant height.我试图显示一个完全覆盖屏幕宽度(如 SMART_BANNER)和 90dp 恒定高度的 admob 广告。

using this code, i can set the height to 90dp, but how can i make the ad width fill the width?使用此代码,我可以将高度设置为 90dp,但是如何使广告宽度填充宽度?

AdSize adSize = new AdSize(deviceSpecificWidth, 90);

According tothis , these are the standard sizes of SMART_BANNER根据这个,这些都是SMART_BANNER的标准尺寸

Screen width x 32|50|90屏幕宽度 x 32|50|90

can i force the smart banner to only use 90dp height in every device?我可以强制智能横幅在每个设备中只使用 90dp 的高度吗?

I would suggest to use the newly introduced AdMob Adaptive Banners .我建议使用新推出的AdMob 自适应横幅 They don't require adjustments on your side and they utilize all the width available and keeping the aspect ratio (which was a problem before).它们不需要在您身边进行调整,它们利用所有可用的宽度并保持纵横比(这是以前的问题)。

Embed them into a FrameLayout like following将它们嵌入到 FrameLayout 中,如下所示

<FrameLayout
    android:id="@+id/adFragment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_gravity="center|bottom" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM