简体   繁体   中英

Android Ad: Landscape Vs. Screen Auto-rotate

I am developing an app of which all environment are in landscape.

Manifest.xml

    <activity 
        android:name=".Main"
        android:screenOrientation="landscape"/>

Main.java

public class Startup extends Activity implements AdListener {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);   
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                         WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);

    interstitialAd = new InterstitialAd(this, MY_PUBLISHER_ID); // Create an ad.  
    interstitialAd.setAdListener(this); // Set the AdListener.
    AdRequest adRequest = new AdRequest();
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
    interstitialAd.loadAd(adRequest);   

Screenshots:

The Ad loads, but does not appear properly; there is a lot of white blank space at the bottom of the screen (under the ad), and it seems the ad is in portrait mode but chopped as shown below:

渲染图像不正确

However, I discovered that if I GO OUTSIDE the app and set the system screen to be able to SCREEN AUTO_ROTATABLE , then the ad can be displays properly like below:

正确渲染的图像

Question:

  1. I believe interstitialAd could support landscape? But how could that be modified?

  2. If the interstitialAd cannot be modified, how can I force the system to set SCREEN AUTO_ROTATABLE to indirectly solve the problem?

It sounds like this should be configured on the server side as mentioned here: https://developers.google.com/mobile-ads-sdk/docs/dfp/advanced

There is no need to define a separate ad unit for landscape mode. You can simply add the landscape size (eg 480x320 for smartphones) to line items targeting the interstitial ad unit and include a creative with the landscape size in addition to the regular portrait size.

I don't have access to DoubleClick for Publishers so I can't verify if that would work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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