移动AdView中底,Cocos2dx活动 [英] Move AdView to bottom, Cocos2dx Activity
问题描述
请帮我将广告移至屏幕下方
Cocos2dxActivity.this.adView =新的AdView(Cocos2dxActivity.this,AdSize.SMART_BANNER,mediationId()); @燮pressWarnings(德precation)
ViewGroup.LayoutParams ad_layout_params =新ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
Cocos2dxActivity.this.adView.setLayoutParams(ad_layout_params); AdRequest中AdRequest中=新AdRequest中();
请注意:这是关于的Cocos2D-X 3.1.1,虽然早期版本应该就这类似于
Cocos2dxActivity使用的FrameLayout
作为其最顶端的布局。为了达到你想要什么,这已经被改为 RelativeLayout的
- 在Cocos2dxActivity类,有一个的init()
您应该修改方法。还有一个名为 mFrameLayout
A类变量 - 只需将其类型更改为 RelativeLayout的
和名称相应地,你的IDE应该告诉你还有什么地方可以更改。
至于旗帜本身,你应该将它添加到时候给它这个布局参数 RelativeLayout的
:
RelativeLayout.LayoutParams relParams =新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);
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();
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);
这篇关于移动AdView中底,Cocos2dx活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!