마침내 텍스트 뷰의 높이를 기준으로 텍스트의 크기를 조정하는 코드를 찾았습니다. Source,하지만 난이 기능에 텍스트를 전달하는 방법을 받고 있지 않다, 내 텍스트가 다른 의도자동 Textview 안드로이드
public int getHeightOfMultiLineText(String text,int textSize, int maxWidth) {
TextPaint paint = new TextPaint();
paint.setTextSize(textSize);
int index = 0;
int linecount = 0;
while(index < text.length()) {
index += paint.breakText(text,index,text.length(),true,maxWidth,null);
linecount++;
}
Rect bounds = new Rect();
paint.getTextBounds("Yy", 0, 2, bounds);
// obtain space between lines
double lineSpacing = Math.max(0,((linecount - 1) * bounds.height()*0.25));
return (int)Math.floor(lineSpacing + linecount * bounds.height());
}
문자열에 텍스트를 저장하고 getHeightofMultiLineText (ur_string_text, 12,10)에 전달합니다. – KOTIOS
오류가 발생하고 있습니까? – KOTIOS
tv.setText (receivingdata)에 전달하는 방법; 이 함수에 ?? – user2451541