【发布时间】:2023-01-31 19:25:23
【问题描述】:
这是我的代码:
AndroidView(
modifier = modifier,
factory = {
val view =
LayoutInflater.from(context).inflate(R.layout.native_ad, null, true)
val adView = view.findViewById<TemplateView>(R.id.medium_ad_template)
adView.apply {
AdLoader.Builder(context, context.getString(AR.string.native_unit_id))
.forNativeAd { nativeAd ->
setStyles(NativeTemplateStyle.Builder().build())
setNativeAd(nativeAd)
}
.build()
.loadAd(request)
}
view
}
)
native_ad.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.ads.nativetemplates.TemplateView
android:id="@+id/medium_ad_template"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:gnt_template_type="@layout/gnt_medium_template_view" />
</LinearLayout>
广告在屏幕导航上不断刷新
我尝试在第一次加载时设置一个标签并继续检查它以查看广告是否已加载,但视图已刷新且标签重置为默认值
【问题讨论】:
-
您能否指定问题并添加一些屏幕截图?
标签: android admob android-jetpack-compose android-jetpack