codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

Android WebView: Do CSS pixels always equal DIPs if width=device-width and scale=1.0?


By : , Category : android

If you want to convert physical <-> DIP pixel then you need to use window.devicePixelRatio (or DisplayMetrics): the densities names (mdpi, hdpi, etc..) are simply brackets/categories - two devices in the same category could have a different devicePixelRatio value.

For what you're doing it might be a good idea to take a look at Pixel-Perfect UI in the WebView.

ReLated :

Try this code

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    int content_height = [[_textWebview stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"] integerValue];
    CGRect rect = _textWebview.frame;
    rect.size.height = content_height+15;
    _textWebview.frame = rect;
}

Here is the css I use for img in webview

img {max-width: 100%;height: auto;margin-left: auto;margin-right: auto;}

If you want every img width to be 100% just replace max-width to width

Try

myWebView.getSettings().setUseWideViewPort(true);

see WebSettings

Tells the WebView to use a wide viewport. The default is false.

Remove Width="Auto" from WebView. Don't give any width/height to any control. Grid will expand according to size and hence WebView also.

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .