Is there a way to get the amount of pixels (length and height) based off the text being showed?
I'm creating a global message box.
Text length in pixels
Moderator: Martin
- digitalstone
- Posts: 342
- Joined: 21 Oct 2017 12:36
- Location: The Netherlands
Text length in pixels
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)
Re: Text length in pixels
Quite to difficult to do, even though I think it is possible.
Maybe the better way is to get the bound x,y of the element id.
What is the purpose of getting the amount of pixel from the message box?
Maybe the better way is to get the bound x,y of the element id.
What is the purpose of getting the amount of pixel from the message box?
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
- digitalstone
- Posts: 342
- Joined: 21 Oct 2017 12:36
- Location: The Netherlands
Re: Text length in pixels
What do you mean with the element id?Desmanto wrote:Quite to difficult to do, even though I think it is possible.
Maybe the better way is to get the bound x,y of the element id.
What is the purpose of getting the amount of pixel from the message box?
I'm building the messagebox based on a widget btw
Getting the amount of pixels is to determine the dimensions of the message box.
I like things to be futureproof while not taking up more space than needed.
But i guess i could make it just 1 size for every possible message ever if it's not possible.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)
Re: Text length in pixels
Oh, I thought you wanna retrieve the size in certain UI Element. Measuring the text pixel seems quite difficult unless you use monospace font. Non-monospace font has kerning, which makes the length varies depend on the content. Counting based on the number of char will give only rough estimation.
So maybe you can use rough estimation based on the char count.
So maybe you can use rough estimation based on the char count.
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
- digitalstone
- Posts: 342
- Joined: 21 Oct 2017 12:36
- Location: The Netherlands
Re: Text length in pixels
Alright thanks.
Already thought it was more difficult than worthy of implementation.
I'll just see what i can do with a monospace font, if i can setup any that is. But i'll check it out.
Already thought it was more difficult than worthy of implementation.
I'll just see what i can do with a monospace font, if i can setup any that is. But i'll check it out.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)
- digitalstone
- Posts: 342
- Joined: 21 Oct 2017 12:36
- Location: The Netherlands
Re: Text length in pixels
Btw, Monospace is the fontname.
It's right inside the font options of the widget.
It's right inside the font options of the widget.
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)