我正在android应用中创建一个足球积分表,但无法对齐文本。有没有一种方法可以完美对齐。我正在从服务器上的MySQL中获取数据。
这是JSON解析的代码:
JSONObject jsonObject = new JSONObject(result);
int success = jsonObject.getInt("success");
if(success == 1){
JSONArray under8_club_league = jsonObject.getJSONArray("under8_club_league");
for(int i=0; i < under8_club_league.length(); i++){
JSONObject under8_club_league_object = under8_club_league.getJSONObject(i);
String team_name = under8_club_league_object.getString("team_name");
int played = under8_club_league_object.getInt("played");
int won = under8_club_league_object.getInt("won");
int lost = under8_club_league_object.getInt("lost");
int draw = under8_club_league_object.getInt("draw");
String GD = under8_club_league_object.getString("gd");
int points = under8_club_league_object.getInt("points");
String line = team_name + "\t\t\t\t\t\t" + played + " " + won + " " + lost + " " + " " + draw + " " + GD + " " + points;
adapter.add(line);
答案 0 :(得分:0)
如果您只是使用文本并尝试将其隔开,则可以使用一种作弊的方法并使用等宽字体(请不要实际执行此操作)。
我建议使用TableView和TableRow对象,然后将每个文本放在其自己的TextView中,并将这些textView添加到每个TableRow中-TableView将对齐每一行的列。