Change color of a text section in a widget

Post your questions and help other users.

Moderator: Martin

Post Reply
Christofer
Posts: 31
Joined: 27 May 2017 11:19

Change color of a text section in a widget

Post by Christofer » 01 May 2018 10:23

Hi there!

In an Automagic widget, is it somehow possible to change the fill color of a text section without changing the fill color of the whole text element? For example, having the base color of the text in black, but change a few words to red.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Change color of a text section in a widget

Post by Desmanto » 01 May 2018 12:12

You mean a single text element but with 2 different color? (example first 2 words is green and the rest are red.) You can't, each single text element can only have single color. If you need to change certain part, you should split them to 2 different text element instead, and modify each by itself.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Christofer
Posts: 31
Joined: 27 May 2017 11:19

Re: Change color of a text section in a widget

Post by Christofer » 01 May 2018 13:15

Yes. Ah, too bad... The words to be colored won't appear in the same place (the length of of text before the differently colored text changes from time to time), so I can just split it up in different elements. I'll try build it in a other way.

Thanks for the answer!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Change color of a text section in a widget

Post by Desmanto » 01 May 2018 16:44

I just remember digitalstone ever asked the similar here : viewtopic.php?f=5&t=7135
He is trying to auto adjust the text box element size depends on the text length.

I found out that Automagic has supported Monospace font in the widget font type. So you can try to use monospace font and count the text box size. Use length(text) to count the length of the text and multiply by the number of the total character that the text box can hold, make it a round number, so easier to arrange. Example if your text box is 400 and can hold 10 characters, means each char is 40 pixels (monospace font has same length for all char). Adjust the first textbox width according to the length of the text. Then then second text box, adjust the x from the left based on the length of the first text box. Then modify each textbox color individidually. Takes several script to do each round, but can be done

Original
This is text one. This is text two

Text one shortened
Text 1. The text one has shortened
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
digitalstone
Posts: 342
Joined: 21 Oct 2017 12:36
Location: The Netherlands

Re: Change color of a text section in a widget

Post by digitalstone » 01 May 2018 19:06

Yes Monospace is a very functional font.
It's fontsize equals exactly each character's length in pixels.
Aesthetically not much to look at (unless you go for a 1984 look 8-) ) but perfect for calculating these type of text tricks.

In the end though, it's also about asking yourself if (merely) a cosmetic feature is worth the increasing hassle.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)

Post Reply