scrollbar on table content, android phonegap - android

I need to have a table content with scrollbar in an android app using html, javascript and css.
I already tried to search a lot of examples and plugins but with no success, many of them are telling me to do like this one below. I have to put over-flow:auto, some size to the height and display:block, but I tried that and all the content was aligned only to the first column and didn't work.
<table>
<thead>
<tr>
<th>title 01</th>
<th>title 02</th>
<th>title 03</th>
<th>title 04</th>
</tr>
</thead>
<div>
<tbody>
<tr>
<td> content row col 01</td>
<td> content row col 02</td>
<td> content row col 03</td>
<td> content row col 04</td>
</tr>
</tbody>
</div>
</table>
Please, I need some solution.
Thanks.

Finally, I found a solution.
I used this jquery plugin jquery.jtablescroll.js.
Import js on your page like this:
<script type="text/javascript" src="jquery/jquery.tablescroll.js"></script>
and into html page put the table with content like the example below:
<table id="tableId">
<thead>
<th>Column Header 01</th>
<th>Column Header 02</th>
<th>Column Header 03</th>
</thead>
<tbody>
<tr>
<td>Column Content</td>
<td>Column Content</td>
<td>Column Content</td>
</tr>
</tbody>
</table>
and in javascript of your html you'll need to activate jtablescroll to your table, do like this one below, setting the id of your table and height of it:
jQuery(document).ready(function($)
{
$('#tableId').tableScroll({height:600});
});
Naturally, you don't wanna create a table with static content, so remember to activate the plugin to your table in javascript just after the content had been gotten from server and rows of the table had been added dinamically to the tbody for example like this:
jQuery('#tableId tbody').append(contentList);
I hope this can help somebody that had this problem.

Related

Outlook on Android (11) image size exploding

Templates that had previously worked are now exhibiting very odd behavior on Outlook for Android (11). Our logo image is strangely HUGE and wrapped in all sorts of weird ways. The actual file is 8bit, PNG, 300x79. Outlook desktop and OWA appear fine, as does iOS mail, Gmail etc. Our image code is this:
<table width="100%" role="presentation" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" border="0" style="max-width:640px;background:#ffffff !important">
<tr>
<td bgcolor="#ffffff" width="10"> </td>
<td bgcolor="#ffffff" style="padding-top:5px;">
<!--[if mso]>
<table width="50%"><tr><td>
<img width="280" src="cid:logo" style="text-align: right; width: 280px; border: 0; text-decoration:none; vertical-align: baseline;" border="0" />
</td></tr></table>
<div style="display:none;">
<![endif]-->
<img style="max-width:300px !important;height:auto;" src="cid:logo" border="0" />
<!--[if mso]>
</div>
<![endif]-->
</td>
</tr>
</table>
What we're seeing here is actually a portion of the letter "A". The orange is a 10px high orange bar that runs across the top of our emails.
I've cleared all data and cache from my Outlook mobile. No difference. Before I go any crazier, am I missing something here in this code? What's even weirded is if I change the template to just text and do not include the image (inline displayed using contentid) is Outlook on Android still shows the image as below.
Turns out it was minified CSS. When I took the exact same CSS, un-minified it and put that in the head section, Outlook mobile worked as expected. Swap back to minified and it broke again.

Why do left-aligned tables in an email stack on the Android Gmail App when they contain full width images?

I'm aware the Android Gmail App does not allow media queries so should show the desktop version of the e-mail.
For the most part it does, however there is one section that should sit side-by-side and for some reason on the Android Gmail app, it stacks, it appears to be due to the image being the same width as the table, because it works fine if there is just text in each left-aligned table.
I'm wondering if anyone else has come across this issue and found a solution?
The only solution I've come across so far is to reduce the width of the image, which then leaves a gap to the right of the image.
Code below:
<table class="mobile_wrapper" bgcolor="#000000" border="0" width="640" cellpadding="0" cellspacing="0" style="background-color:#000000; width:640px;">
<tr>
<td>
<table align="left" class="mobile_wrapper" bgcolor="#000000" border="0" width="320" cellpadding="0" cellspacing="0" style="background-color:#000000;width:320px;">
<tr>
<td>
<img src="https://placehold.it/320x389" alt="image" width="100%" height="389" border="0" align="top" class="mobile_image" style="display:block;" />
</td>
</tr>
</table>
<table align="left" class="mobile_wrapper" bgcolor="#000000" border="0" width="50%" cellpadding="0" cellspacing="0" style="background-color:#000000;width:320px;">
<tr>
<td>
<img src="https://placehold.it/320x389" alt="image" width="100%" height="389" border="0" align="top" class="mobile_image" style="display:block;" />
</td>
</tr>
</table>
</td>
</tr>
</table>
I'm not sure why this was down-voted - but for anyone else that has this issue it was actually a simple fix - I think it's to do with Gmail's auto-sizing.
The way to get around it is to ensure the image has a width of 100% within a table with a fixed width - that way if the table shrinks - the image will shrink with it.
I almost had it - but for some reason had a 50% width on the second left-aligned table.

Html Email Template on Android not responsive

I have created an email template utilizing tables,tr,td's. All seems to be ok except the fact that on android phones it is not re-sizing to fit the screen.. it works perfectly on apple products.. I have searched some online and the word seems to be that android has disabled responsiveness for some reason. There has to be a way around this as most all emails are checked on mobile phones and quite a few of them are on android.
Have you tried setting up Viewport metatag to your html template?
<meta name="viewport" content="width=device-width, initial-scale=1">
I definitely agree with setting:
<meta name="viewport" content="width=device-width, initial-scale=1">
I would also suggest using an css-inlining tool such as this one http://templates.mailchimp.com/resources/inline-css/ (if your external source doesn't already do it on your behalf) to ensure that gmail picks up the styles.
In addition, in terms of general scaling issues in Gmail, I would suggest adding the following block just before your closing body element (as recommended here: http://freshinbox.com/blog/gmail-on-ios-increases-font-size-on-some-emails/):
<div style="display:none; white-space:nowrap; font:15px courier; line-height:0; color: #ffffff;">
----------------------------------------
</div>
As some other have noted, Gmail and some Android stock email clients do not support media queries. To cover these clients, you need Hybrid Design.
Hybrid design achieves a responsive, shape-shifting layout without using media queries. At its core, it uses max-width and min-width to impose rigid baselines (allowing some movement) and imposes a fixed, wide width for Outlook who is shackled to desktop anyway. Once a mobile-friendly baseline is set, media queries progressively enhance the email further in clients that support it (like iOS Mail).
Here is a basic 2-column scaffolding from Fabio Carneiro's code samples on GitHub (all credit to him!):
<!doctype html>
<html>
<body style="margin:0;">
<center>
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<!-- // 2-COLUMN SCAFFOLD [CENTERING, FLUID] -->
<tr>
<td align="center" height="100%" valign="top" width="100%">
<!--[if mso]>
<table align="center" border="0" cellspacing="0" cellpadding="0" width="660">
<tr>
<td align="center" valign="top" width="660">
<![endif]-->
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:660px;">
<tr>
<td align="center" valign="top" style="font-size:0;">
<!--// DEVELOPER NOTES:
1. Setting font-size:0; is necessary to ensure
that there is no extra spacing introduced
between the centering divs that wrap each
of the columns. //-->
<!--[if mso]>
<table align="center" border="0" cellspacing="0" cellpadding="0" width="660">
<tr>
<td align="left" valign="top" width="330">
<![endif]-->
<div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;">
<!--// DEVELOPER NOTES:
1. To have each column center upon stacking,
wrap them in individual divs, set the same
max-width and width as the table within it,
and set display to inline-block; using
vertical-align is optional.
2. Setting min-width determines when the two
columns of this block will wrap; in this
case, when the total available width is
less than or equal to 480px. //-->
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;">
<tr>
<td align="center" valign="top">
<!-- // REPLACE WITH BLOCK -->
<p style="background-color:#2BAADF; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">LEFT</p>
<!-- REPLACE WITH BLOCK // -->
</td>
</tr>
</table>
</div>
<!--[if mso]>
</td>
<td align="left" valign="top" width="330">
<![endif]-->
<div style="display:inline-block; max-width:50%; min-width:240px; vertical-align:top; width:100%;">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width:330px;">
<tr>
<td align="center" valign="top">
<!-- // REPLACE WITH BLOCK -->
<p style="background-color:#51BBE5; color:#FFFFFF; font:16px Helvetica, sans-serif, normal; margin:0 !important; padding:10px;">RIGHT</p>
<!-- REPLACE WITH BLOCK // -->
</td>
</tr>
</table>
</div>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]-->
</td>
</tr>
</table>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]-->
</td>
</tr>
<!-- 2-COLUMN SCAFFOLD [CENTERING, FLUID] // -->
</table>
</center>
</body>
</html>
There are more scaffolds and patterns in that repo and elsewhere, but this shows the basic principle in action.
If your talking about the Gmail app on Android (which is what you tagged this question as) the app itself does not mobilize with media queries or style tags, it strips them as you have found. Make sure you inline as much as possible to get the best support across email clients.
There is a way to get it to mobilize by using a combination of fluid and fixed width tables. But it won't be pixel perfect. Think about fixed width tables as the blocks inside a fluid table (width=100%). Tables will stack on top of one another once they reach the width they are set for. This is of course for any multi column layout. Single column is the safest approach because there is no need to focus on stacking.
Don't hesitate to use tables nested in tables that are nested in tables. For the approach I mentioned above of using fluid and fixed width tables, for a two column layout you would have your outer table be 100% width and two fixed width tables inside that table that are a specific width and aligned right and left.
It is possible to get it to look decent in Gmail app, but there are two concepts you have to ask yourself, are you going for graceful degradation or lowest common denominator?
Graceful degradation meaning it looks great in a lot of email clients and decent in gmail app or lowest common denominator being single column and designing around that.
Android doesn't support responsive emails but there are some workarounds.
For example you can change all the to . This will solve the problem. It will also make the text bold in those cells but you can change the styles to force it to render as you like.
If you are talking about Gmail on Android, Gmail app doesn't support responsive either but you can force it to render as desktop. Unfortunately no workarounds for Gmail and this will be the only solution so far.
It is all explained step by step here:
Hot to get a responsive email to work on Android

android keyboard changes layout of phonegap application

I create a quiz application for android using phonegap framework, The first page of application contains a sign up form, i want to get user information. my code is
<table class="m">
<tr>
<td class="left">Name:</td>
<td class="right"><input class="t" type="text"/></td>
</tr>
<tr>
<td class="left">Image:</td>
<td class="right"><input class="t" type="text"/></td>
</tr>
<tr>
<td class="left">Email:</td>
<td class="right"><input class="t" type="text"/></td>
</tr>
<tr>
<td class="left">Phone:</td>
<td class="right"><input class="t" type="text"/></td>
</tr>
</table>
But when i click on the text field the android keyboard appears on the screen and also it changes the height of my layout, finally the first input field is lifted up and not visible to user
How can i fix this problem
I believe your html codes are too simple, may be it should be a little bit more complicated. In my case, I put the table inside the div tag, and set the width and height of the div by JavaScript according to the screen width and height of different phones and browsers.
Also, the font-size are set at a ratio with respect to the screen width so that actual font size seen by the user is approximately the same for different phone.
then, use the scrollheight of the div to make sure the user can see the focused input textbox when it is being edited.

100% width tables don't work in Gmail Android

I'm trying to build a responsive email – it's actually working pretty great across the board, except for some small pieces that aren't co-operating in Gmail for Android.
I have these seriously simple black stripes that sit at the top of the email as a decorative element:
<table width="100%" cellpadding="0" cellspacing="0" align="center" valign="top">
<tr><td width="100%" height="11" bgcolor="#000000"></td></tr>
<tr><td width="100%" height="2" bgcolor="#FFFFFF"></td></tr>
<tr><td width="100%" height="1" bgcolor="#000000"></td></tr>
<tr><td width="100%" height="30" bgcolor="#FFFFFF"></td></tr>
</table>
Yet they don't display as anything more than a tiny strip of black and white that resembles an ultra-thin exclamation point on the Gmail Android app.
Likewise, there is a footer that isn't spanning the full width of the email:
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#000000">
<tr>
<td>
<table width="650" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#000000">
<tr>
<td align="right" class="footer">
<img src="images/footer.png" />
</td>
</tr>
</table>
</td>
</tr>
</table>
Any suggestions on how to make these span the full width of the email?
If you haven't found a solution try
style="width:100%!important" like
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" bgcolor="#000000" style="width:100%!important">
Gmail likes to strip most of the CSS, but if you add a label !important will keep them most of the time.
So remind Gmail that 100% means 100% by adding min-width:100% to our <table>.
source
After extensive testing the solution as follows will work for any vertical spacing issues across all email clients (available on Litmus), incl. Gmail App on Andriod.
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="width:100% !important;">
<tr>
<td bgcolor="#00a0cc" height="25" style="background:#00a0cc;height:25px;line-height:0;font-size:0;"> <br /></td>
</tr>
</table>
Key point is to apply width:100% !important to the table, will not work on applying to the td.
This is also the best solution for replacing vertical spacer images.
Looks like we have faced same full-width table color issue on Gmail app; while my case was on iOS version. You can see the background-color cannot fill with full-width below:
My fix is adding min-width:100% in css style, i.e.
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="min-width: 100%; color: #555555; background-color:#def6f7" bgcolor="#def6f7">
I'm not familiar with making clients/sites/etc for anything that's not designed for PC, so I'm not sure if this will work or not, but try doing this.
<center>
<h1 style="color:#888888;">Android Client Header</h1>
<p>Demonstration</p>
</center>
<hr color="#000000" style="height:11px;">
<hr color="#FF0000" style="height:2px;">
<hr color="#000000" style="height:1px;">
<hr color="#FF0000" style="height:30px;">
<h3 style="color:#0070ff;">Content 1</h3>
<p color="#808080">E-mail Here</p>
<hr color="#000000">
<center>
<h1 style="color:#db880f;text-size:10px;">Android Client Footer</h1>
<p style="color:#888888;">Demonstration</p>
</center>
Even though you lose the "table" element feature, this is a sample example I came up with, trying my best to matchup your color and size settings for the line decorations.

Categories

Resources