我使用单个textView来显示视图。由于UpCase字母和整数采用不同的边距或填充,因此它们没有正确对齐我正在尝试添加
name: AnyName
age: 23
caseId: anyID
然后
setColor(caseByTv, "By:	" + caseDetail.getUpdatedByUser().trim(), 0, 3, 0xFF777777);
setColor(serviceTypeTv, "Type:\t\t" + caseDetail.getType().trim(), 0, 5, 0xFF777777);
setColor(updatedDateTv, "Updated:\\u0009\\u0009" + caseDetail.getUpdatedOnDate().trim(), 0, 8, 0xFF777777);
setColor(orderDetailTv, "Order #\u0009\u0009" + caseDetail.getOrderNumber().trim(), 0, 8, 0xFF777777);
setColor(nameTv, "Name: " + caseDetail.getName().trim(), 0, 8, 0xFF777777);
setColor(emailTv, "Email: " + caseDetail.getEmail().trim(), 0, 7, 0xFF777777);
setColor(phoneNoTv, "Phone: " + caseDetail.getPhone().trim(), 0, 7, 0xFF777777);
setColor(categoryTypeTv, "Category: " + caseDetail.getCaseCategory().trim(), 0, 10, 0xFF777777);**strong text**
其中setColor
public void setColor(TextView view, String fulltext, int startIndex, int endIndex, int color) {
Spannable str = new SpannableString(fulltext);
str.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(R.color.guest_connection_grey)), startIndex, endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
view.setText(str);
}
我尝试了多种添加标签的方法。首先,选项卡没有显示任何空格,我知道我可以通过连续使用两个textView来实现它。我能以这种方式实现我的目标。
答案 0 :(得分:3)
试试这个
rightSpace()
public StringBuilder rightSpace(int max, String name) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(name);
for (int i = 0; i < max - name.length(); i++) {
stringBuilder.append(" ");
}
return stringBuilder;
}
功能
E/RESULT1: 10302351 30
E/RESULT2: 10 30
E/RESULT3: nilesh rathod Nilesh
<强>输出强>
SearchBar