在Android </div>中发送电子邮件时,<div>不会创建列

时间:2012-09-18 12:31:41

标签: android html email

我使用 html替换所有标签,以便在Android 中作为电子邮件发送。 我的html在这里显示。

<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
<style>
body {
    background: #FFFFFF;
    margin: auto;
    font-family: Helvetica;
    color: #808080;
}
a {
    color: #3A41A1;
}
#wrapper {
    width: 537px;
    margin: auto;
}
#header {
    width: 100%;
    color: #000000;
    margin-bottom: 15px;
}
#content {
    width: 100%;
    background: #DAFFF5;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 14px;
    display: table;
}
.row {
    display: table-row;
    padding: 8px;
    border: 1px solid black;
}
.cell-header {
    padding: 8px;
    display: table-cell;
}
.cell-left {
    display: table-cell;
    padding: 8px;
    border: 1px solid black;
    color: #006BF2;
    width: 90px;
}
.cell-right {
    display: table-cell;
    padding: 8px;
    border: 1px solid black;
    color: #000000;
    text-align: left;
}
</style>
</head>
<body>
    <div id="wrapper">
        <div id="header">
            ##HEADER## &nbsp; <a href="#">##TEXT1##</a>, <a href="#">##TEXT2##</a>, <a href="#">##TEXT3##</a>
        </div>

        <div id="content">
            <div class="row">
                <div class="cell-header" style="color:#FF6A00; font-weight:bold; text-transform:capitalize; text-align: left;">##NAME##</div>
                <div class="cell-header" style="text-align: right;"><a href="#" style="color:#006BF2;">##LINK##</a></div>
            </div>
            <div class="row">
               <div class="cell-left">
                   ##TITLE##
               </div>
               <div class="cell-right">
                   ##VALUE##
               </div>
            </div>
            <div class="row">
               <div class="cell-left">
                   ##TITLE##
               </div>
               <div class="cell-right">
                   ##VALUE##
               </div>
            </div>
            <div class="row">
               <div class="cell-left">
                   ##TITLE##
               </div>
               <div class="cell-right">
                   ##VALUE##
               </div>
            </div>
        </div>
    </div></body></html>

但是没有在邮件中对齐。显示为

##TITLE##
##VALUE##

我正在使用Html.fromHtml()。 Html.fromHtml()支持<div>。那有什么问题呢?我该如何解决这个问题?

由于

2 个答案:

答案 0 :(得分:1)

根据此blogpost和该类的source code,看起来<style>不是受支持的标记...但是再次<html>,{{1 }}和<head>都不是......所以让我感到困惑。

此StackOverflow answer表明只支持通过HTML进行基本格式化,因此执行更复杂的基于CSS的布局可能效果不佳。但是,正如refhat所建议的那样,内联CSS可能会起作用。 (您可以查看上面链接的源代码,但是简短的初始搜索没有返回“样式”的任何结果,因此您甚至可能无法进行内联CSS。)

此外,假设您正在使用<body>来执行此操作... sounds like并非所有电子邮件应用程序都支持HTML,如果用户运行此设置,这可能是一个糟糕的设计决策程序没有支持此功能的电子邮件客户端。

答案 1 :(得分:0)

您需要在表格布局中构建它并提供内联CSS