[TIMOB-20477] Android: Request to support Superscript/Subscript Attributed String
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-09-05T07:43:16.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 6.1.0 |
| Components | Android |
| Labels | attributedString |
| Reporter | Shuo Liang |
| Assignee | Hans Knöchel |
| Created | 2016-02-29T00:44:48.000+0000 |
| Updated | 2016-11-23T18:49:44.000+0000 |
Description
Customer request our SDK to support Superscript/Subscript Attributed String like we did for Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE.
Ref:
http://developer.android.com/reference/android/text/style/SuperscriptSpan.html
http://developer.android.com/reference/android/text/style/SubscriptSpan.html
Hello, I think this feature is very much needed to support strings with scientific notations and native android supports this feature. [Chemical Compound](http://i38.tinypic.com/qy8n7m.png) [Scientific Notation of Number](http://android.okhelp.cz/images/img/textview-superscript-issue.jpg) [Mathematical Equation](http://i.stack.imgur.com/Wnsmn.png) Thanks
PR: https://github.com/appcelerator/titanium_mobile/pull/8308 [> Expected result <](https://abload.de/img/bildschirmfoto2016-09bsqll.png) Demo:
var win = Titanium.UI.createWindow({ backgroundColor: '#ddd', }); var attr = Titanium.UI.createAttributedString({ text: 'x2 + y3, hello world!', attributes: [ { type: Titanium.UI.ATTRIBUTE_SUPERSCRIPT_STYLE, range: [1, 1] }, { type: Titanium.UI.ATTRIBUTE_SUPERSCRIPT_STYLE, range: [6, 1] }, { type: Titanium.UI.ATTRIBUTE_SUBSCRIPT_STYLE, range: [15, 5] } ] }); var label = Titanium.UI.createLabel({ height: 50, color: "#000", attributedString: attr }); win.add(label); win.open();PR merged.
Verified using this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0 Appc CLI NPM: 4.2.8 Titanium SDK version: 6.1.0.v20161122053743 Appcelerator Studio, build: 4.8.0.201611121409 Xcode 8.1 GM Android v6.0.1 I installed the app on the device using the demo code above, and the output matched Hans link "Expected Result".