2014-07-06 6 views
1

나는 정말 간단한 질문이 있지만 알아낼 수없는 것 같습니다. 그래서이 상당히 큰 textview 있고 각 단어가 12 개의 텍스트 행을 갖고 싶습니다. 그러나 XML에서 편집 할 때 오직 하나의 android : text 특성 만 가질 수 있습니다. 내가 어떻게 할 수 있니?textView에 더 많은 텍스트 추가 android

<TextView 
     android:id="@+id/textView7" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="6" 
     android:text="speed" 
     android:text="air speed" 
     /> 

그래서 코드에 표시된 것과 같은 텍스트 속성이 더 필요합니다.

+0

'textview.append()'를 사용하여 프로그래밍 방식으로 텍스트 뷰에 텍스트를 추가 할 수 있습니다. – masmic

답변

1

그냥 개행 문자 \n

를 사용
<TextView 
     android:id="@+id/textView7" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="6" 
     android:text="speed\nair speed" /> 
1

당신이 사용하는 자바 코드를 사용하여 텍스트 뷰에 texxt 설정할 수 있습니다 HTml.from HTML처럼 태그 : 당신이 12를 추가 할 수 있습니다 유사

TextView tvInformation = (TextView)findViewById(R.id.tv_information); 
tvInformation.setText(Html.fromHtml("<br>"+"</br>" + "row1 text" + "<br>"+"</br>" + "row2 text"); 

또는 귀하의 요구 사항에 따라 더 많은 행. 이
태그는 문자열에서 \ n을 사용하므로 다음 줄에 사용됩니다.

관련 문제