ICS

2011-12-05 21 views
5

'daki WebView çizimini kopyalar Bir Web Görünümü, diğer öğelerle bir ScrollView içine yerleştirilmiş satır içi bir uygulama yapıyorum. ICS'de, bir Galaxy Nexus cihazında test yapıldığını fark ettim; WebView, görüntülenen öğelerin geri kalanıyla, sayfa çakıldığında, WebView'ın birkaç ms değerinden dolayı yüzmekte görünmesine neden olacak şekilde, görünmüyor. çizim üzerinde gecikmek. Bu, Android'in 2.x sürümlerinde (3.x'te test edilmemiştir) gerçekleşmez. http://www.youtube.com/watch?v=avfBoWmooM4 kayan efektin bir videosu (tam ekran olarak 1080p'de ayarladığınızda net bir şekilde görebilirsiniz)ICS

Bunun neden olabileceğini veya düzeltilebileceğini kimse önerebilir mi?

Ben bir test projesi aşağıda göstermek için kurulum ettik:

package com.martynhaigh.floating_web_view; 

import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.support.v4.app.FragmentActivity; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.webkit.WebView; 
import android.widget.FrameLayout; 
import android.widget.LinearLayout; 
import android.widget.ScrollView; 
import android.widget.TextView; 

public class FloatingWebViewTestActivity extends FragmentActivity { 
    public final int viewId = 0x12345678; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 
     FrameLayout frame = new FrameLayout(this); 
     frame.setId(viewId); 
     setContentView(frame, lp); 

     FloatingWebViewICSFragment fragment = new FloatingWebViewICSFragment(); 
     getSupportFragmentManager().beginTransaction().add(viewId, fragment).commit(); 
    } 

    public static class FloatingWebViewICSFragment extends Fragment { 

     private final String htmlBody = "<html><body><p style=\"font-size:1.5em\">This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. This is a test document. </body></html>"; 

     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
     } 

     @Override 
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 

      TextView textView = new TextView(getActivity().getApplicationContext()); 
      textView.setText("Test Activity"); 

      WebView webView = new WebView(getActivity().getApplicationContext()); 
      webView.loadDataWithBaseURL("file:///android_asset/", htmlBody, "text/html", "UTF-8", "about:blank"); 
      webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); 
      webView.setScrollContainer(false); 

      TextView textView2 = new TextView(getActivity().getApplicationContext()); 
      textView2.setText("Test Activity"); 

      FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); 

      LinearLayout layout = new LinearLayout(getActivity().getApplicationContext()); 
      layout.setLayoutParams(lp); 
      layout.setOrientation(LinearLayout.VERTICAL); 

      layout.addView(textView); 
      layout.addView(webView); 
      layout.addView(textView2); 

      ScrollView scrollView = new ScrollView(getActivity().getApplicationContext()); 
      scrollView.setLayoutParams(lp); 
      scrollView.addView(layout); 

      return scrollView; 
     } 

    } 
} 

cevap

1

ben şimdi nedenini nasıl düzeltebilirim bilmiyorum ama. WebView içeriği, ayrı bir çalışan iş parçacığında android.webkit.WebViewCore tarafından oluşturulur. Birbirleriyle iletişim kuruyorlar. WebView yeniden oluşturulduğunda, WebViewCore'a "lütfen oluştur" mesajını gönderir ve WVC hazır olduğunda, sonucu geri gönderir. Buradaki nokta, render işlemlerinin, diğer UI öğelerinin işlenmesiyle senkronize olmamasıdır - ayrı, ui olmayan bir iş parçacığında yapıldığı gibi.

UI iş parçacığını tüm oluşturma çabalarıyla engellemekten kaçınmak istediler. Bu çok kibar. Ama seninki gibi başka problemlere sebep oluyor.

İlgili konular