0

I am developing an app that uses local files. In index.html file i have multiple links to different local files like: settings.html, add.html, edit.html and ... Problem is when i run app in android studio and smart phone, when i click on any link, before loading content a fast screen flash with white background shows up. Look at this gif:

enter image description here

How can i disable this white flash?

MainActivity.java:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView webView=findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setDomStorageEnabled(true);
    webView.loadUrl("file:///android_asset/index.html");

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<WebView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/webView"/>

</LinearLayout>
Amir
  • 23
  • 8
  • This can help you: https://stackoverflow.com/questions/23391350/android-getting-white-screen-with-fragment-transaction – WannaBe Sep 23 '22 at 10:34
  • @WannaBe Thanks, But I'm a total beginner in android studio and java. I don't know what to do with linked codes. can you please modify my codes or give me a few pointers? – Amir Sep 23 '22 at 10:55

1 Answers1

0

I had a similar problem and I fixed it this way : in the styles.xml file I put

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">

instead of

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Eric Aya
  • 69,473
  • 35
  • 181
  • 253