{"id":21130064,"url":"https://github.com/xuyisheng/TextViewForFullHtml","last_synced_at":"2025-07-09T01:32:10.282Z","repository":{"id":82022114,"uuid":"45598103","full_name":"xuyisheng/TextViewForFullHtml","owner":"xuyisheng","description":"init commit","archived":false,"fork":false,"pushed_at":"2021-10-24T11:35:45.000Z","size":499,"stargazers_count":280,"open_issues_count":5,"forks_count":48,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-10T00:25:36.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xuyisheng.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-11-05T08:33:54.000Z","updated_at":"2024-10-04T08:57:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3a7c8ce-25ed-462c-94e6-9301b3e868e5","html_url":"https://github.com/xuyisheng/TextViewForFullHtml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xuyisheng/TextViewForFullHtml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuyisheng%2FTextViewForFullHtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuyisheng%2FTextViewForFullHtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuyisheng%2FTextViewForFullHtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuyisheng%2FTextViewForFullHtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuyisheng","download_url":"https://codeload.github.com/xuyisheng/TextViewForFullHtml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuyisheng%2FTextViewForFullHtml/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264375349,"owners_count":23598363,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T05:32:14.351Z","updated_at":"2025-07-09T01:32:09.866Z","avatar_url":"https://github.com/xuyisheng.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"readme":"# TextViewForFullHtml\n\nTextViewForFullHtml是对原生TextView解析Html格式文本的增强。\n\n## 原生TextView对Html的支持\n\n原生的TextView同样支持Html的显示，但是Develop Doc里面也写了，并不是支持所有的Html标签，例如，font的size，默认的Android系统只支持small、normal、big三种，但是不支持具体的字号，比如textsize=14这种。\n\n## TextViewForFullHtml\n\nTextViewForFullHtml这个库的目的在于在同一个TextView中给不同的文字设置不同大小的字体，当然，顺便也支持了其他的一些效果，比如对齐方式、字体风格等。\n\n具体可以看示例图：\n\n![](https://github.com/xuyisheng/TextViewForFullHtml/blob/master/art/demo.png)\n\n## 代码使用示例\n\n目前给出的String示例是ActionScript的，Html应该也可以支持（需要具体测试）。\n\n```\nString mContentTextSize = \"\u003cTEXTFORMAT LEADING=\\\"2\\\"\u003e\u003cP ALIGN=\\\"LEFT\\\"\u003e\u003cFONT FACE=\\\"Microsoft Yahei,微软雅黑\\\" SIZE=\\\"24\\\" COLOR=\\\"#333333\\\" LETTERSPACING=\\\"0\\\" KERNING=\\\"0\\\"\u003e\u003cFONT SIZE=\\\"40\\\"\u003e我是很大的字……\u003c/FONT\u003e我居然比旁边的字小\u003cFONT SIZE=\\\"14\\\"\u003e我最小...啊啊啊\u003c/FONT\u003e\u003cFONT SIZE=\\\"12\\\"\u003e......居然可以设置不同的字体字号\u003c/FONT\u003e\u003c/FONT\u003e\u003c/P\u003e\u003c/TEXTFORMAT\u003e\";\nString mContentGravityCenter = \"\u003cTEXTFORMAT LEADING=\\\"2\\\"\u003e\u003cP ALIGN=\\\"CENTER\\\"\u003e\u003cFONT FACE=\\\"Microsoft Yahei,微软雅黑\\\" SIZE=\\\"24\\\" COLOR=\\\"#333333\\\" LETTERSPACING=\\\"0\\\" KERNING=\\\"0\\\"\u003e我先来个居中对齐!\u003c/FONT\u003e\u003c/P\u003e\u003c/TEXTFORMAT\u003e\";\nString mContentGravityRight = \"\u003cTEXTFORMAT LEADING=\\\"2\\\"\u003e\u003cP ALIGN=\\\"RIGHT\\\"\u003e\u003cFONT FACE=\\\"Microsoft Yahei,微软雅黑\\\" SIZE=\\\"24\\\" COLOR=\\\"#333333\\\" LETTERSPACING=\\\"0\\\" KERNING=\\\"0\\\"\u003e我是来右对齐的!\u003c/FONT\u003e\u003c/P\u003e\u003c/TEXTFORMAT\u003e\";\nString mContentStyle = \"\u003cTEXTFORMAT LEADING=\\\"2\\\"\u003e\u003cP ALIGN=\\\"LEFT\\\"\u003e\u003cFONT FACE=\\\"Microsoft Yahei,微软雅黑\\\" SIZE=\\\"24\\\" COLOR=\\\"#333333\\\" LETTERSPACING=\\\"0\\\" KERNING=\\\"0\\\"\u003e我可以设置很多不同的字体风格,比如:\u003cB\u003e加粗\u003c/B\u003e、\u003cI\u003e斜体\u003c/I\u003e、\u003cU\u003e下划线\u003c/U\u003e。\u003c/FONT\u003e\u003c/P\u003e\u003c/TEXTFORMAT\u003e\";\nString mContentUrl = \"\u003cTEXTFORMAT LEADING=\\\"2\\\"\u003e\u003cP ALIGN=\\\"LEFT\\\"\u003e\u003cFONT FACE=\\\"Microsoft Yahei,微软雅黑\\\" SIZE=\\\"24\\\" COLOR=\\\"#333333\\\" LETTERSPACING=\\\"0\\\" KERNING=\\\"0\\\"\u003e我可以设置一个超链接,牛逼吗 \u003cFONT COLOR=\\\"#0000ff\\\"\u003e\u003cA HREF=\\\"我是超链接\\\" TARGET=\\\"_blank\\\"\u003e\u003cFONT COLOR=\\\"#6698ff\\\"\u003e\u003cU\u003e快戳我看看\u003c/U\u003e\u003c/FONT\u003e\u003c/A\u003e\u003c/FONT\u003e\u003c/FONT\u003e\u003c/P\u003e\u003c/TEXTFORMAT\u003e\";\n```\n\n使用方法：\n\n```\n// 示例:演示设置不同文字的字体大小\nTextViewForFullHtml textViewTextSize = new TextViewForFullHtml(this);\ntextViewTextSize.loadContent(mContentTextSize);\n// 示例:演示设置不同文字的对齐风格——居中\nTextViewForFullHtml textViewGravityCenter = new TextViewForFullHtml(this);\ntextViewGravityCenter.loadContent(mContentGravityCenter);\n// 示例:演示设置不同文字的对齐风格——右对齐\nTextViewForFullHtml textViewGravityRight = new TextViewForFullHtml(this);\ntextViewGravityRight.loadContent(mContentGravityRight);\n// 示例:演示设置不同文字的字体风格\nTextViewForFullHtml textViewStyle = new TextViewForFullHtml(this);\ntextViewStyle.loadContent(mContentStyle);\n// 示例:演示设置不同文字的超链接\nTextViewForFullHtml textViewUrl = new TextViewForFullHtml(this);\ntextViewUrl.loadContent(mContentUrl);\n```\n\n使用非常简单，用TextViewForFullHtml替换掉TextView并调用loadContent方法即可。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuyisheng%2FTextViewForFullHtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuyisheng%2FTextViewForFullHtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuyisheng%2FTextViewForFullHtml/lists"}