Dear All,
I´ve been playing around with creating a 9-patch drawable, and use it as a label background. The label should stretch to fit the text inside of it, and for that I´ve found 3 different methods in the forum.
I´ve attached a small app that´ll demonstrate the results of each method. It keeps writing the word test untill 85% of the screen width is reached, and then starts on a new line. All you need to do is keep clicking on one of the buttons at the bottom; each of them triggers one of the 3 methods. So for instance, to see what happens when using method one, click the first button over and over again to see what happens. Once you click another button, the process resets with the new method.
The first method is the most succesful one, with only one issue: The padding at the bottom of the label becomes more and more, the more the label grows. First it looks like this:
But then after some lines, we can see how much the lower padding has grown:
This in fact also happens if I do not load the 9 patch image on the button.
It also does this for the padding on the right edge (which happens for all methods btw), which can be seen while there´s still only the first line. It keeps on expanding.
The 2nd method makes the drawable too big - big enough for 3 lines - and won´t start expanding vertically till the 4th line is added.
The 3rd and last method doesn´t show the lines from 2nd and up till the line has been completed.
Does anyone have any good ideas to add here, so I can get things right?
Thanks in advance!
I´ve been playing around with creating a 9-patch drawable, and use it as a label background. The label should stretch to fit the text inside of it, and for that I´ve found 3 different methods in the forum.
I´ve attached a small app that´ll demonstrate the results of each method. It keeps writing the word test untill 85% of the screen width is reached, and then starts on a new line. All you need to do is keep clicking on one of the buttons at the bottom; each of them triggers one of the 3 methods. So for instance, to see what happens when using method one, click the first button over and over again to see what happens. Once you click another button, the process resets with the new method.
The first method is the most succesful one, with only one issue: The padding at the bottom of the label becomes more and more, the more the label grows. First it looks like this:
But then after some lines, we can see how much the lower padding has grown:
This in fact also happens if I do not load the 9 patch image on the button.
It also does this for the padding on the right edge (which happens for all methods btw), which can be seen while there´s still only the first line. It keeps on expanding.
The 2nd method makes the drawable too big - big enough for 3 lines - and won´t start expanding vertically till the 4th line is added.
The 3rd and last method doesn´t show the lines from 2nd and up till the line has been completed.
Does anyone have any good ideas to add here, so I can get things right?
Thanks in advance!