Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲

Android TextView 與 HTML 結合用法

編輯:關於 Android 程式設計

Android 的 TextView 本身支援部分 HTML 標籤,例如粗體、顏色、字級與連結。開發者可透過 Html.fromHtml 將 HTML 字串轉為可顯示的格式,再設定給 TextView。

若 HTML 中包含圖片,除了 fromHtml 外,還需要實作 ImageGetter,讓 TextView 能取得 Drawable 並顯示。若沒有使用自訂標籤,TagHandler 可傳入 null。這方式適合顯示簡單的富文字內容。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © Android教程網 All Rights Reserved