About Admob Banner Rotation!

Hi guys,

I have successfully added the Admob using the plugin that we have in this forum. I need a little bit more customization. What I want is:

  1. My game is in Landscape mode ( which is ok and working )
  2. I want the Admob in Portrait mode ( which is the problem )

In the Plugin Manifest.xml I have:

<activity android:name=".AdPluginActivity"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation"
              [B][I]android:screenOrientation="portrait"[/I][/B]>

After the build what I’m getting is:

<activity android:name=".AdPluginActivity" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation" [B][I]android:screenOrientation="landscape"[/I][/B]>

which mean, build is rotating or changing the orientation of the plugin view! If I set my game orientation in Portrait mode, then Admob is setting in Portrait mode properly!

So, I want to play my game in Landscape but Admob view in Portrait rotation!

I have done all of these thing in IOS and it’s working there very well but yet need to know how I can deal it in Android.

Thanks in advance
-grinder

I’m actually not sure you can do that. The landscape/portrait mode is a per-activity setting; ie both the unity view and the ad banner view will rotate together. The only way I can see that working is if you rotate the ad view before adding it to the left/right side of your landscape composition hierarchy, but I think doing that requires some support in the AdMob library (which I’m not sure they have).

I think there is no function to like setRotation or so in the Adview of Admob. What I’m looking now is: Adview is inherited from View and view should have a transform. so, if I rotate that transform and set it to the Adview, then it should work. I’m new at Android so, still surfing on the doc :frowning:

In iPhone it’s pretty simple as I know how to do it. LOL

I have tried to rotate the Adview but it didn’t work :frowning: Here is the sample code:

				//as the adview width is 48dip, So the value will be 24
				RotateAnimation rAnim = new RotateAnimation(0,-270, 24,24);                
				rAnim.setInterpolator(new LinearInterpolator());        
				rAnim.setFillAfter(true);
				rAnim.setFillEnabled(true);        
				adView.setAnimation(rAnim);

But it didn’t respond! When I used it without Unity, then it’s work well. In iPhone you can force the view to rotate the view to certain angle and it has direct Transform to manipulate the view matrix but I didn’t find any property for Android view.

I use this to set the ad to landscape and align left

LinearLayout layout = new LinearLayout(this);
layout.setOrientation([B]LinearLayout.HORIZONTAL[/B]);
addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));

RelativeLayout.LayoutParams adParams = new     RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
adParams.addRule([B]RelativeLayout.ALIGN_PARENT_LEFT[/B]);
	        
adView = new AdView(this);
layout.addView(adView, adParams);

And this to create an fade in animation

// Fade the ad in over 4/10 of a second.
showAnimation = new AlphaAnimation( 0.0f, 1.0f );
showAnimation.setDuration( 400 );
showAnimation.setFillAfter( true );
showAnimation.setInterpolator( new AccelerateInterpolator() );

And just this to play it

adView.startAnimation( showAnimation );

Not sure if any of that helps you, but hopefully some of it does :slight_smile:

Anyone have a quick tip for getting the adMob ad to appear in the top right in landscape mode? (I tried modifying DTreble’s code but no luck)

you can use Erik Admob plugin for Android. Please do a search in this forum. That one worked well for Landscape or portrait based on the game settings!

I’ve got it working in landscape, now I just want the ad to appear in the top right corner (instead of the top center). I’ve tried playing around like this in the ‘Plugins/Android/src/org/example/AdMobTest/AdMobTestActivity.java’ file

LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.HORIZONTAL);
		
addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
		
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		
adView = new AdView(this);
layout.addView(adView, adParams);

, but it doesn’t seem to make any difference. Any ideas?

C’mon you Android gurus, this should be trivial for you! This is the last piece of the puzzle and then we can submit Crazy Snowboard to the marketplace…

…got it working. The problem was I hadn’t installed ‘ant’ properly and didn’t know you had to re-build the .jar when you made changes. Thanks to the guys over at GameResort for their help!

Look out Marketplace, here we come.

I have the same problem…please help us!!!

I have the same problem…

Prime31 is close to a solution, check out his plugin’s thread. I just counter rotated every camera in our game, so I can run in portrait but look landscape.