问题
Help me please to move ads to bottom of the screen
Cocos2dxActivity.this.adView = new AdView(Cocos2dxActivity.this, AdSize.SMART_BANNER, mediationId());
@SuppressWarnings("deprecation")
ViewGroup.LayoutParams ad_layout_params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Cocos2dxActivity.this.adView.setLayoutParams(ad_layout_params);
AdRequest adRequest = new AdRequest();
回答1:
Note : this is in regard to cocos2d-x 3.1.1, though earlier versions should be similar in regard to this.
Cocos2dxActivity uses a FrameLayout
as its top most layout. In order to achieve what you want, this has be changed to a RelativeLayout
- in Cocos2dxActivity class, there is an init()
method which you should edit. There is also a class variable called mFrameLayout
- just change its type to RelativeLayout
and name accordingly, and your IDE should tell you where else to change.
As to the banner itself you should give it this layout parameters when adding it to the RelativeLayout
:
RelativeLayout.LayoutParams relParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
relParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
relParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
来源:https://stackoverflow.com/questions/25089759/move-adview-to-bottom-cocos2dx-activity