Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android WebView在emulator上显示动画GIF,在真实设备上显示静态图像_Android_Webview - Fatal编程技术网

Android WebView在emulator上显示动画GIF,在真实设备上显示静态图像

Android WebView在emulator上显示动画GIF,在真实设备上显示静态图像,android,webview,Android,Webview,我有活动布局: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.an

我有活动布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/webView"
        android:layout_width="300dp"
        android:layout_height="300dp"
        android:layout_marginTop="8dp"
        android:clickable="false"
        android:layerType="software"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

</android.support.constraint.ConstraintLayout>

当我在emulator上启动此应用程序时-我看到动画GIF,但当我在设备上启动此应用程序时-我看到静态图像而不显示动画。为什么?

在chrome版本为66+的Android 7.0以后的设备上,我也面临同样的问题


正如删除android时所建议的那样:layerType=“software”对我有效。

您的设备和仿真器是否在同一api版本上>
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView webView = findViewById(R.id.webView);
        webView.setBackgroundColor(0x00000000);
        webView.loadUrl("http://gifok.net/images/2018/05/10/1212.gif");
    }
}