【问题标题】:<div> does not create column when sending email in android<div> 在 android 中发送电子邮件时不创建列
【发布时间】:2012-09-18 20:59:31
【问题描述】:

我使用 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() 支持&lt;div&gt;。那么问题是什么?我该如何解决这个问题?

谢谢

【问题讨论】:

  • 你找到解决办法了吗?

标签: android html email


【解决方案1】:

根据该类的blogpost 和一些source code,看起来&lt;style&gt; 不是受支持的标签...但又是&lt;html&gt;&lt;head&gt;&lt;body&gt; 不是要么......所以这让我有点困惑。

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

另外,假设您使用Intent 来执行此操作...sounds like 并非所有电子邮件应用程序都支持 HTML,如果运行该程序的用户不支持,从长远来看这可能是一个糟糕的设计决策有一个支持此功能的电子邮件客户端。

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • Html.fromHtml() 不支持 标签
    • @AshaSoman:Html.fromHtml() 也不支持 CSS。如果您尝试通过ACTION_SEND 发送 HTML,则不能依赖第三方邮件应用程序来处理任意 HTML。
    • 我想发送一封表格格式的电子邮件。我该怎么做?
    猜你喜欢
    • 1970-01-01
    • 2013-04-03
    • 2012-01-21
    • 2014-02-23
    • 2022-08-13
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多