項目發布成安卓包后,由於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; }