项目发布成安卓包后,由于Laya对Activity包了一层 game_plugin_get_view,导致穿山甲Banner广告位置无法贴底问题的解决方案,由于困扰较久特此记录,
1.新建一个activity_main.xml文件
2.在MainActivity的initEngin中重新设置ContentView
具体代码如下
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="HardcodedText" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- BannerView的Container --> <FrameLayout android:id="@+id/game_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="#D5D5D5" /> <FrameLayout android:id="@+id/banner_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="#D5D5D5" android:layout_alignParentBottom="true"/> </RelativeLayout>
public void initEngine() { mProxy = new RuntimeProxy(this); mPlugin = new GameEngine(this); mPlugin.game_plugin_set_runtime_proxy(mProxy); mPlugin.game_plugin_set_option("localize","false"); mPlugin.game_plugin_set_option("gameUrl", App_Startup_Entry); mPlugin.game_plugin_init(3); View gameView = mPlugin.game_plugin_get_view(); this.setContentView(R.layout.activity_main); this.gameContainer = findViewById(R.id.game_container); this.banner_container = findViewById(R.id.banner_container); this.gameContainer.addView(gameView); isLoad=true; }