Move AdView to bottom, Cocos2dx Activity

巧了我就是萌 提交于 2019-12-11 10:08:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!