1. Download our Official Android App: Forums for Android!

WebView position wrong with hardware acceleration

Discussion in 'Android Lounge' started by akoka, Oct 5, 2011.

  1. akoka

    akoka Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Oct 5, 2011

    Oct 5, 2011
    1
    0
    5
    One might think that this is a bug unless somebody has a better explanation. When I turn hardware acceleration off, I'm able to position the webView using the setX and setY methods and it works great but it seems like setX and setY have no effect when hardware acceleration is on and the webView seems to always render at 0,0. Following is a little snippet of code which can be used to re-create the problem easily.

    Any help is appreciated. Thanks.

    Code (Text):
    1.  
    2.  
    3. [LIST=1]
    4. [*]// Create layout  
    5. [*]            RelativeLayout layout = new RelativeLayout(this);  
    6. [*]            setContentView(layout);  
    7. [*]              
    8. [*]            // Create area  
    9. [*]            FrameLayout area = new FrameLayout(this);  
    10. [*]            area.setX(500);  
    11. [*]            area.setY(100);  
    12. [*]              
    13. [*]            // Add area to view  
    14. [*]            layout.addView(area, 640, 480);  
    15. [*]              
    16. [*]            WebView wv = new WebView(this);  
    17. [*]            wv.getSettings().setJavaScriptEnabled(true);  
    18. [*]            wv.getSettings().setPluginsEnabled(true);  
    19. [*]            wv.getSettings().setAllowFileAccess(true);  
    20. [*]            wv.loadUrl("someURL");  
    21. [*]            area.addView(wv, 640, 480);
    22. [/LIST]
    23.  
    24.  
     

    Advertisement

Share This Page

Loading...