1

我正在通过 WP-CodeBox 插件写一篇关于 Android 的博客,并希望将 layout.xml 添加到博客中,如下所示:

<pre><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <ImageView android:id="@+id/icon"
        android:layout_width="@dimen/notification_large_icon_width"
        android:layout_height="@dimen/notification_large_icon_height"
        android:background="@android:drawable/bg_tile"
        android:scaleType="center"
        />

</LinearLayout></pre>

在 HTML 模式下,当我将编辑模式更改为可视模式时,xml 消失了!请帮助我如何在 xml 模式下显示 xml 而不会出现格式错误。wordpress 中还有其他 xml 编辑插件吗?谢谢!

4

1 回答 1

1

你可以用这个荧光笔。这将为您的 XML 提供以下输出(使用 Eclipse 样式):

<pre style='color:#000000;background:#ffffff;'><span style='color:#7f0055; '>&lt;</span><span style='color:#7f0055; '>LinearLayout</span> xmlns:android=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>http</span><span style='color:#2a00ff; '>:</span><span style='color:#7f0055; font-weight:bold; '>//</span><span style='color:#3f3fbf; '>schemas.android.com</span><span style='color:#3f3fbf; '>/apk/res/android</span><span style='color:#2a00ff; '>"</span>

    android:layout_width=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>match_parent</span><span style='color:#2a00ff; '>"</span>
    android:layout_height=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>match_parent</span><span style='color:#2a00ff; '>"</span>
    <span style='color:#7f0055; '>></span>
    <span style='color:#7f0055; '>&lt;</span><span style='color:#7f0055; '>ImageView</span> android:id=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>@+id/icon</span><span style='color:#2a00ff; '>"</span>
        android:layout_width=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>@dimen/notification_large_icon_width</span><span style='color:#2a00ff; '>"</span>
        android:layout_height=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>@dimen/notification_large_icon_height</span><span style='color:#2a00ff; '>"</span>
        android:background=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>@android:drawable/bg_tile</span><span style='color:#2a00ff; '>"</span>
        android:scaleType=<span style='color:#2a00ff; '>"</span><span style='color:#2a00ff; '>center</span><span style='color:#2a00ff; '>"</span>
        <span style='color:#7f0055; '>/></span>

<span style='color:#7f0055; '>&lt;/</span><span style='color:#7f0055; '>LinearLayout</span><span style='color:#7f0055; '>></span>
</pre>

它看起来像这样:

在此处输入图像描述

于 2012-12-31T18:27:24.277 回答