how to define a vertical linearlayout in my kotlin code so that the views don't overlap between the banner and other content?
The problem is that admob ads cover the video player content when in landscape orientation
and this in myprogrammatcally
override fun onShowCustomView(view: View, callback: CustomViewCallback, requestedOrientation: Int) {
val currentTab = tabsManager.currentTab
if (customView != null) {
try {
callback.onCustomViewHidden()
} catch (e: Exception) {
logger.log(TAG, "Error hiding custom view", e)
}
return
}
try {
view.keepScreenOn = true
} catch (e: SecurityException) {
logger.log(TAG, "WebView is not allowed to keep the screen on")
}
originalOrientation = getRequestedOrientation()
customViewCallback = callback
customView = view
//setRequestedOrientation(requestedOrientation)
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR)
val decorView = window.decorView as FrameLayout
fullscreenContainerView = LayoutInflater.from(this).inflate(R.layout.layout_fullscrren_video, null) as LinearLayout
fullscreenContainerView?.setBackgroundColor(ContextCompat.getColor(this, R.color.black))
if (view is FrameLayout) {
val child = view.focusedChild
if (child is VideoView) {
videoView = child
child.setOnErrorListener(VideoCompletionListener())
child.setOnCompletionListener(VideoCompletionListener())
}
} else if (view is VideoView) {
videoView = view
view.setOnErrorListener(VideoCompletionListener())
view.setOnCompletionListener(VideoCompletionListener())
}
decorView.addView(fullscreenContainerView, COVER_SCREEN_PARAMS)
fullscreenContainerView?.addView(customView, 0, LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0).also { it.weight = 1f })
fullscreenContainerView?.findViewById<AdView>(R.id.ad_view)?.let { AdsManager.get.initAdView(it) }
decorView.requestLayout()
setFullscreen(enabled = true, immersive = true)
currentTab?.setVisibility(INVISIBLE)
}
myxml code
layout_fullscreen_video.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
include layout="@layout/layout_ad_banner"
</LinearLayout>
and This my layout_ad_banner
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:adSize="BANNER"
app:adUnitId="@string/banner_ad_unit_id" />
</FrameLayout>