Good morning, I have an application designed to work on both a smartphone and a tablet. When it runs on the tablet, I want to enlarge the text of my web view so that users can read the text better and fill in all the empty space, if possible.
This code that I use to do this trick:
//Webview Zoom if( UIUtils.isTablet(getActivity())) { if(UIUtils.isICS()) { webView.getSettings().setTextZoom(130); } else { int currentTextSizeIndex = lyricsView.getSettings().getTextSize().ordinal(); if ( currentTextSizeIndex+1 < lyricsView.getSettings().getTextSize().values().length ) webView.getSettings().setTextSize( lyricsView.getSettings().getTextSize().values()[currentTextSizeIndex+1] ); } }
So, I check if I am on the tablet, and I check which user version of the OS. Infact from API Level 14 I can use setTextZoom , which allows me to set the text scaling of the page as a percentage (default is 100). This solution is much more scalable, because I can, for example, give the user the opportunity to increase or decrease the text as necessary in increments of +10 or -10 percent.
Until API level 14, I have to use setTextSize , which use the enum parameter as the parameter (default is NORMAL). TextSize - Enum to indicate the size of the text. SMALLEST - 50%. SMALLER - 75%. NORMAL - 100% LARGER - 150%. LARGEST - 200%.
Thus, I can use only these 5 costants and not so scalable (but this is the only way to transfer this function to 90% of phones that do not have ICS: D).
The problem is that webView.getSettings().setTextSize(TextSize.LARGER); acts differently when I show a text view in different tables, and this is really not normal.
At the moment I am testing Samsung Galaxy Tab and Kindle Fire. These are the technical specifications of GSMArena:
Samsung Galaxy Tab P1000
Screen
Type TFT capacitive touchscreen, 16M colors
Size 600 x 1024 pixels, 7.0 inches (~ 170 pixels per pixel)
Amazon Kindle Fire
Screen
IPS Type TFT capacitive touchscreen, 16M colors
Size 1024 x 600 pixels, 7.0 inches (~ 170 pixels per pixel)
As you can see, they have the same resolutions, inches and ppi! Now I will show you 2 screenshots (of the same web content content) that form these devices, so you can opt out of what I'm talking about.
KindleFire: 
Galaxy Tab: 
On the Galaxy tab with textSize LARGE, the text is too big, and this is visible. Thus, for such a device it is better to show the default default text (and let the user choose if you place more of it). But how can I find out what textSize looks best by default? Since NORMAL is suitable for the Galaxy Tab and too small for the Kindle Fire, and LARGE is too large for the galaxy tab, but ideal for the Kindle. I do the test only on these two devices, but I have to support all the tablets, I have to find some parameters, differencs in the devices, to say: ok on this device, because the permissions are small. I put more / normal, instead, on this, because it is a big resulation, I can put it more (sort of).
Have you ever encountered this problem? How can I solve it?