J'ai développé un jeu en xcode en utilisant cocos2d-x & converti en android.Puis j'ai ajouté google play services annonce, mais il est affiché dans leftsidecorner. Je veux l'afficher au milieu. S'il vous plaît, aidez-moi à trouver la solution.google play services annonce affiche dans le coin dans android
private Point getDisplaySize(Display d)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
{
return getDisplaySizeGE11(d);
}
return getDisplaySizeLT11(d);
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private Point getDisplaySizeGE11(Display d)
{
Point p = new Point(0, 1);
d.getSize(p);
return p;
}
private Point getDisplaySizeLT11(Display d)
{
try
{
Method getWidth = Display.class.getMethod("getWidth", new Class[] {});
Method getHeight = Display.class.getMethod("getHeight", new Class[] {});
return new Point(((Integer) getWidth.invoke(d,(Object[]) null)).intValue(),
((Integer) getHeight.invoke(d, (Object[]) null)).intValue());
}
catch (NoSuchMethodException e2) // None of these exceptions should ever occur.
{
return new Point(-1, -1);
}
catch (IllegalArgumentException e2)
{
return new Point(-2, -2);
}
catch (IllegalAccessException e2)
{
return new Point(-3, -3);
}
catch (InvocationTargetException e2)
{
return new Point(-4, -4);
}
}
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
int width = getDisplaySize(getWindowManager().getDefaultDisplay()).y;
FrameLayout.LayoutParams adParams = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
adParams.gravity = Gravity.BOTTOM;
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("HASH_DEVICE_ID")
.build();
adView.loadAd(adRequest);
adView.setBackgroundColor(Color.BLACK);
adView.setBackgroundColor(0);
addContentView(adView,adParams);
_appActiviy = this;
}
Affichez votre mise en page. –
Je n'utilise aucune disposition. J'utilise uniquement le code d'annonce google play services dans le fichier .java. – arunkumar
Si vous affichez quelque chose, vous utilisez une mise en page. –