I have an app which takes data from a database and then displays it as a list of articles. The data is taken and put in a recyclerView with web views in it.
One specific article has this html:
<div style="position: absolute; height: 100%; background: url('https://www.softray.it/wp-content/uploads/2015/10/home-test-6.2.png') no-repeat;">
<div style="height: 100%; width: 50%; margin-left: auto; margin-right: auto;display: table-cell; vertical-align: middle; text-align: center;">
<h1 style="padding: 10px; text-align: center; font-family: 'Open Sans', sans-serif; color: #ffffff;">SOFTRAY TECHNOLOGY</h1>
<p style="padding-left: 5px; text-align: center; color: #ffffff; font-family: 'Open Sans', sans-serif;">La potenza del mobile re-inventa le applicazioni business e un nuovo stile di IT</p>
</div>
</div>
*Sorry for the messy html I just don't have a decent editing tool on the database.
The problem here is that my background image doesn't display and even the second div
doesn't center vertically the way it should.
I tried to attach html
and body
tags to my data before displaying it but still no background image loads.
holder.webView.loadData("<html style='height:100%;'><body style='height:100%;margin:0;padding:0;'>" + s + "</body></html>", "text/html", "utf-8");
I know I probably have to give an element a fixed height but I want to adapt to any screen. Any tips?
EDIT:i just need to get the height in pixels of the webview content so I can set that in the html
tag.
Problem with this is that I need to know this dimension before I load my data.