In one of the activity of my application, I am displaying user names with their points in front of the names.
The name may have different number of characters, but I want the strings to end at the same place.
I am able to provide correct number of spaces and the strings are equal in character lengths but the characters take uneven space and ruin the symmetry of the strings.
Is there any work around for this?
Here's the code :
private String separateNamePoints{
String text="";
//text is separated by ,
String[]splittedRawText=rawText.split(",");
String name=(splittedRawText)[0];
String points=(splittedRawText)[1];
int pointsLength=points.length();
int reqSpaceLength=40-name.length();
String space="";
for(int i=0;i<reqSpaceLength;i++){
space+=" ";
}
if(pointsLength==1)
space+=" ";
else if(pointsLength==2)
space+=" ";
else if(pointsLength==3)
space+=" ";
text=name+space+points;
return text;
}
And here's the image :