Mat*_*ski 9 android admob android-theme firebase
我使用Theme.AppCompat.DayNight.NoActionBar
主题为我的应用程序.当我加载adMob interstital时,某些颜色会在"夜间"模式下被破坏(即在RecyclerView中).
屏幕:
那些不正确的颜色来自"notnight"值.当我关闭应用程序并再次运行它一切都很好.当我杀了应用程序时,我有同样的情况.
活动代码:
public class MainActivity extends AppCompatActivity {
static {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_AUTO);
}
private ArrayList<String> planetList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
populateRecycler();
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
PlanetAdapter adapter = new PlanetAdapter(planetList, getApplicationContext());
recyclerView.setAdapter(adapter);
InterstitialAd interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId("ca-app-pub-543543543/543543543");
AdRequest adRequest = new AdRequest.Builder().build();
interstitialAd.loadAd(adRequest);
}
private void populateRecycler() {
for (int i = 0; i < 20; i++) {
planetList.add("TEST");
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我评论interstitialAd.loadAd(adRequest)
一切都好.
你可以在这里找到整个项目: github
Roy*_*erg 19
该问题可能是由WebView
重置UI模式引起的,这可以通过WebView
手动实例化来解决.
这样做后我没有看到这个问题(Application.oncreate()
在这个特定的应用程序中):
if (nightMode != AppCompatDelegate.MODE_NIGHT_NO) {
Log.d(TAG, "Manually instantiating WebView to avoid night mode issue.");
try {
new WebView(getApplicationContext());
} catch (Exception e) {
Log.e(TAG, "Got exception while trying to instantiate WebView to avoid night mode issue. Ignoring problem.", e);
}
}
AppCompatDelegate.setDefaultNightMode(nightMode);
Run Code Online (Sandbox Code Playgroud)
来源:https://groups.google.com/forum/#! msg/ google-admob-ads- sdk/ OZzHq_- wAFY/ K50jClZcBAAJ
归档时间: |
|
查看次数: |
1020 次 |
最近记录: |