Smart String is no longer supported, please check out T8TextSize lib
http://b4x.com/android/forum/threads/t8textsize-library-smart-string.56851/
Hello every one
This library is for adjusting the text size automatically or manual with the following features:
1.SingleLine1
This sub tries to increase or decrease the single line text size and preserve the aspect ratio as Long As the height of the text Is Not greater than the height of the view.in other word you can increase your text size until you have space in width and height,and the text will be single line always and your aspect ratio is always preserved(IT’S ACCURACY IS ACCEPTABLE BUT IS NOT 100%)
NOTE1: The text size can not be changed with every 1dip
NOTE2: Your text in base layout should not be larger than 1 line
2.SingleLine2
This sub tries to fit your text in the view and then set maximum size if you have space in width and height of the view.and it’s always will be one line.this sub is similar to singleline1 but with two difference
1-Aspect ratio was not preserved and text can fit in the view
2-your text in base layout can be longer than one line but after set singleline2 it will be 1 line
3.Multiline1
This sub increase or decrease your text size as long as you have space in width and height and number of lines is smaller than your given maximum lines number
4.Multiline2
This sub increase or decrease your text size as long as you have space in width and height this sub not related to number of lines
NOTE: This sub has an argument named CanBeLarger.by using this option you can have more control over the size of your text if it’s not be larger than view spaces then the text size will not be increased.in other word this option is useful when you want to keep your base text size in larger devices
5.SetManualSize
with this sub you can give a scale rate for base layout and then your text size will be larger in large devices and be smaller in small devices with your given scale rate.
NOTE:This sub don’t preserve your aspect ratio and not depended on available spaces in width or height in other word you are free to do what do you want
6.SetSameStyle
With this sub You can Set any changes on a view and apply that textsize and font to same viewes with same height and width
This option is for decrease cpu , ram , battery usage with reduce calculates
7.SetExactLineNumber
Set your text to given line number without any change in text size
8.Ellipsize,SetLineSpace,SetPadding
This library is a collection of tools for strings
and you can ellipsize(cut) your text or set spaces between lines or fit the text in every position that you want Such as top or center
9.RichString1 – 4
This sub help you to use richstring library simpler with just call this subs
IMPORTANT NOTE1: If you use multiline1 or multiline2 and set your line space larger or smaller than default.your text size will be adapted but the position of text in your view will not be able to auto padding but you can set it manualy with SetPadding sub.this issue may be solved in next update
IMPORTANT NOTE2:Please don’t use this automatic text size library for adjust every text in your activity
Because this library adjusting text size with calculate and can be a reason for decrease free ram.In other word if you use this sub too much and always then maybe your ram free space decreased or cpu usage be high in weak devices
You have two solutions for solve this problem:
1-you can use SameStyle sub for decrease calculates
2-or Use activity first time option I think
AND AT LAST
This is my first library and may have many bug.please help and report any bug to solve it in next updates
*Required Libraries:
Java object , StringUtils ,RichString
Update 1.1:Fixed an issue with singleline2 and post updated
Update 1.2:Fixed an issue with B4A 4.30
http://b4x.com/android/forum/threads/t8textsize-library-smart-string.56851/
Hello every one
This library is for adjusting the text size automatically or manual with the following features:
1.SingleLine1
This sub tries to increase or decrease the single line text size and preserve the aspect ratio as Long As the height of the text Is Not greater than the height of the view.in other word you can increase your text size until you have space in width and height,and the text will be single line always and your aspect ratio is always preserved(IT’S ACCURACY IS ACCEPTABLE BUT IS NOT 100%)
NOTE1: The text size can not be changed with every 1dip
NOTE2: Your text in base layout should not be larger than 1 line
2.SingleLine2
This sub tries to fit your text in the view and then set maximum size if you have space in width and height of the view.and it’s always will be one line.this sub is similar to singleline1 but with two difference
1-Aspect ratio was not preserved and text can fit in the view
2-your text in base layout can be longer than one line but after set singleline2 it will be 1 line
3.Multiline1
This sub increase or decrease your text size as long as you have space in width and height and number of lines is smaller than your given maximum lines number
4.Multiline2
This sub increase or decrease your text size as long as you have space in width and height this sub not related to number of lines
NOTE: This sub has an argument named CanBeLarger.by using this option you can have more control over the size of your text if it’s not be larger than view spaces then the text size will not be increased.in other word this option is useful when you want to keep your base text size in larger devices
5.SetManualSize
with this sub you can give a scale rate for base layout and then your text size will be larger in large devices and be smaller in small devices with your given scale rate.
NOTE:This sub don’t preserve your aspect ratio and not depended on available spaces in width or height in other word you are free to do what do you want
6.SetSameStyle
With this sub You can Set any changes on a view and apply that textsize and font to same viewes with same height and width
This option is for decrease cpu , ram , battery usage with reduce calculates
7.SetExactLineNumber
Set your text to given line number without any change in text size
8.Ellipsize,SetLineSpace,SetPadding
This library is a collection of tools for strings
and you can ellipsize(cut) your text or set spaces between lines or fit the text in every position that you want Such as top or center
9.RichString1 – 4
This sub help you to use richstring library simpler with just call this subs
IMPORTANT NOTE1: If you use multiline1 or multiline2 and set your line space larger or smaller than default.your text size will be adapted but the position of text in your view will not be able to auto padding but you can set it manualy with SetPadding sub.this issue may be solved in next update
IMPORTANT NOTE2:Please don’t use this automatic text size library for adjust every text in your activity
Because this library adjusting text size with calculate and can be a reason for decrease free ram.In other word if you use this sub too much and always then maybe your ram free space decreased or cpu usage be high in weak devices
You have two solutions for solve this problem:
1-you can use SameStyle sub for decrease calculates
2-or Use activity first time option I think
AND AT LAST
This is my first library and may have many bug.please help and report any bug to solve it in next updates
*Required Libraries:
Java object , StringUtils ,RichString
Update 1.1:Fixed an issue with singleline2 and post updated
Update 1.2:Fixed an issue with B4A 4.30
Attachments
Last edited: