某些手機(例如Samsung S6或S7)無法啓動我的android webview應用程序。這是我從谷歌Play商店的了:Android應用程序(Webview)由於閃屏而崩潰
java.lang.RuntimeException:
at android.view.DisplayListCanvas.throwIfCannotDraw (DisplayListCanvas.java:260)
at android.graphics.Canvas.drawBitmap (Canvas.java:1420)
at android.graphics.drawable.BitmapDrawable.draw (BitmapDrawable.java:545)
at android.widget.ImageView.onDraw (ImageView.java:1286)
at android.view.View.draw (View.java:18318)
at android.view.View.updateDisplayListIfDirty (View.java:17296)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.updateDisplayListIfDirty (View.java:17291)
at android.view.View.draw (View.java:18080)
at android.view.ViewGroup.drawChild (ViewGroup.java:3966)
at android.view.ViewGroup.dispatchDraw (ViewGroup.java:3752)
at android.view.View.draw (View.java:18321)
at com.android.internal.policy.DecorView.draw (DecorView.java:919)
at android.view.View.updateDisplayListIfDirty (View.java:17296)
at android.view.ThreadedRenderer.updateViewTreeDisplayList (ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.updateRootDisplayList (ThreadedRenderer.java:698)
at android.view.ThreadedRenderer.draw (ThreadedRenderer.java:806)
at android.view.ViewRootImpl.draw (ViewRootImpl.java:3128)
at android.view.ViewRootImpl.performDraw (ViewRootImpl.java:2924)
at android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:2516)
at android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1515)
at android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7091)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:927)
at android.view.Choreographer.doCallbacks (Choreographer.java:702)
at android.view.Choreographer.doFrame (Choreographer.java:638)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:913)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6682)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410)
這似乎是我的啓動畫面,這是它:
activity_main.xml中:
//splashscreen fullscreen
<ImageView
android:id="@+id/splash1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:screenOrientation="portrait"
android:visibility="visible"
android:src="@drawable/redsplashscreen"
/>
//shows the webview fullscreen
<WebView
android:id="@+id/web1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
MainActivity.java片段:
boolean splashFinished = false;
@Override
public void onPageFinished(WebView view, String url) {
//loads splashscreen once till website is loaded
if (!splashFinished) {
//hides loading image
findViewById(R.id.splash1).setVisibility(View.GONE);
//shows webview
findViewById(R.id.web1).setVisibility(View.VISIBLE);
splashFinished = true;
}
有人在這裏說我必須將圖像從「drawable」文件夾移動到「drawable-xxhd」,一個nd我試過了,但是當我想創建一個APK時,android studio會將其移回並更改xml的代碼。
順便說一句,圖像不是很大,我把大小從1.7MB改爲0.7MB。
你能顯示詳細代碼嗎? – KeLiuyue
你想看更多的東西? – electromomo
詳細Logcat和更多關於MainActivity的代碼。 – KeLiuyue