Skip to Content

Set different color in TextView

Oct 23, 2017 at 03:09 PM


avatar image


i have a TextView in my web dynpro abap application. there we have the property "semanticColor". i can also bind this property.

But how can i use this semanticColor inside my coding to set different colors in the TextView depending on the content of my xstring i put inside the TextView ? I mean how to set the color dynamicly inside the web dynpro application ?

br Martin

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Mike Pokraka Oct 24, 2017 at 07:19 AM

Binding is one part, you then also need to update the bound context attribute that now represents the color.

You can do this via the usual methods, wddoinit, wddomodifyview, onaction..., supply_...

if <textviewvalue> = foo. 
    <colorvalue> = ...
    <colorvalue> = ...
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Well, the question is how i can change the color inside an string ? e.g. i have 3 lines in an string field, which i bind to the textView.

Line 1

Line 2

Line 3

I only want to set the first line to another color, and leave line 2 and 3 black. Question is, if this is possible.

br Martin


Sorry, that wasn't clear in your question. You want to apply multiple colors to parts of the same text.

This is not possible with a TextView, you will have to use a FormattedTextView and generate the formatting up front. See app demo_uiel_formatted_text_edit for an example.