2011-12-05 13 views
5

में विवादित वेबव्यू ड्राइंग मैं एक ऐसा एप्लिकेशन बना रहा हूं जिसमें स्क्रॉलव्यू में घोंसला वाले अन्य तत्वों के साथ वेबव्यू इनलाइन है। मैंने देखा है कि आईसीएस में, गैलेक्सी नेक्सस डिवाइस पर परीक्षण करते हुए, वेबव्यू दिखाई देने वाले शेष तत्वों से अलग हो जाता है जब पृष्ठ फहराया जाता है, जिसके परिणामस्वरूप वेबव्यू कुछ एमएस के लायक होने के कारण फ़्लोटिंग दिखाई देता है ड्राइंग पर अंतराल। यह एंड्रॉइड के 2.x संस्करणों में नहीं होता है (3.x पर परीक्षण नहीं किया गया)। फ़्लोटिंग प्रभाव http://www.youtube.com/watch?v=avfBoWmooM4 का एक वीडियो यहां है (यदि आप 1080p पर पूर्णस्क्रीन पर सेट करते हैं तो आप स्पष्ट रूप से देख सकते हैं)आईसीएस

क्या कोई सुझाव दे सकता है कि यह क्यों हो सकता है, या एक फिक्स?

मैं से सेट किया हुआ एक परीक्षण परियोजना, नीचे, प्रदर्शित करने के लिए:

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; 
     } 

    } 
} 

उत्तर

1

मैं अब इसे ठीक करने नहीं जानता, लेकिन मैं कारण। WebView की सामग्री एंड्रॉइड.webkit.WebViewCore द्वारा अपने अलग कार्यकर्ता धागे में प्रदान की जाती है। वे एक दूसरे के साथ संवाद कर रहे हैं। जब वेबव्यू को फिर से प्रस्तुत करने की आवश्यकता होती है तो यह वेबव्यूकोर को "कृपया प्रस्तुत करें" संदेश भेजता है और जब WVC तैयार होता है तो परिणाम वापस भेजता है। मुद्दा यह है कि उनका प्रतिपादन अन्य UI तत्वों के प्रतिपादन के साथ समन्वयित नहीं है - क्योंकि यह एक अलग, गैर-UI धागे पर किया जाता है।

मुझे लगता है कि वे सभी प्रतिपादन प्रयासों के साथ यूई-थ्रेड को अवरुद्ध करने से बचना चाहते थे। वह कितना दयालू हैं। लेकिन यह अन्य समस्याओं का कारण बनता है ... तुम्हारी तरह।

संबंधित मुद्दे