android - Convert dp values to px values usable inside WebView (dp to CSS px) -


I am creating an HTML page from scratch and dynamically inserting it into a value, a WebView .

I am trying to replicate the WebView (inside html) in the actionbar (which appears in the app in other activities) .

I also know the text of the actionbar and its title inside.

I like dimens such a folder ...

mTitleSize = res.getDimensionPixelSize (R.dimen.actionbar_title_text); // 50dp mActionbarH = res.getDimensionPixelSize (R.dimen.actionbar_height); // 25sp

... and by placing them in the html file's CSS.

My problem is that the values ​​above are really big. The height of the action bar and the size of the text are very large, the same dimens values ​​are used to display the actionbars in the rest of the app (not webview, but original Android see inside a relative layout ) and they look great.

Then ... I'm converting 50dp and 25sp values ​​into pixels, not within a single country, see Inside and WebView ? Is the webpage provided in a different way than the original page?

If so, then value dp in px webview and still seeing as the rest of the application ?

I got it

i.e.

< code> res.getDimensionPixelSize (R.dimen.actionbar_height) / res.getDisplayMetrics (). Density

... and the value as CSS in px

Was set.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -