0

I have an banner at the bottom of the screen, and would like to use setScaleX + setScaleY to zoom it to fit the screen width.

Before and after:

Before After

The main different is that, the bottom part of the image is clipped after scaling (you can see the bottom part of the White Horn in the banner is cut)

Below is my code (adView is the banner which dimension is 320x50)

DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            float scale = metrics.widthPixels / metrics.density / 320;
            adView.setScaleX(scale);
            adView.setScaleY(scale);

Any solution? Thanks!

p.s. Some may suggest using Smart Banner as the AdSize of the AdView. However, I can't use Smart Banner for some reasons so I can only play with setScaleX/Y to do the trick.

Kit Ng
  • 993
  • 4
  • 12
  • 24

1 Answers1

2

Set the adSize to SMART_BANNER and layout_width as match_parent

Change in XML

android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"    
Libin
  • 16,967
  • 7
  • 61
  • 83
  • For some reason I am not allowed to use Smart Banner, so I have to use setScaleX/Y to do the work.... – Kit Ng Apr 20 '14 at 07:14