2014-12-11 2 views
0

a busy catTextView에서 구분선을 만드는 방법은 무엇입니까?

그래서 위치 텍스트 뒤에 구분 기호를 넣으면 내 텍스트가 더 선명하고 명확 해집니다. 이름을 굵은 글씨로 쓰고 싶습니다. 누군가가 이것을 도와 주면 감사하겠습니다. 여기 내 코드입니다 :

및 XML 파일 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@string/title_activity_baseball" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="com.example.athletic_project.java.Baseball"> 


<TextView 
    android:id="@+id/textView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:maxLines="80" 
    android:scrollbars="vertical" 
    android:layout_marginTop="10dp" 
    android:text="@string/title_activity_baseball" 
    android:textSize="15sp"/> 

</RelativeLayout> 
+1

이미지가 주어진 URI를 통해 액세스 할 수없는, 그것을 다시 업로드하시기 바랍니다. – Egor

+0

plz 업로드하고자하는 이미지를 – bjiang

답변

0

가장 좋은 방법은 HTML과 텍스트를 포맷 한 다음 텍스트 뷰에이 방법을 통과하는 것입니다 :

TextView t = ... 
String myHtmlText = ... 

t.setText(Html.fromHtml(myHtmlText)); 

경험상, 좀 더 복잡한 텍스트 형식을 사용할 때 html 인코딩이 가장 좋은 방법이라고 생각합니다.

먼저 Activity의 onCreate 메서드에서 XML 정의 TextView를 Java 객체에 할당하려고합니다. 귀하가 제공 한 코드를 내놓고,

public void onCreate(){ 

    setContentView(R.layout.[name of the XML you pasted above]); 

    TextView t = (TextView) findViewById(R.id.textView1); 

    String htmlEncodedText = ... //Define the text here, with a method, resources call or whatever you like 

    t.setText(Html.fromHtml(htmlEncodedText)); 

} 

을 또는 : 그것은 다음과 같이 이루어집니다

TextView textView = (TextView) findViewById(R.id.textView1); 
    textView.setMovementMethod(new ScrollingMovementMethod()); 

    StringBuffer buffer = new StringBuffer(); 
    String NEW_LINE = "<br>"; 
    for(RssMsg rssMsg : gfR.getFeeds()) { 
     buffer.append("Name : <b>" +rssMsg.getName() + "</b>"); 
     buffer.append(NEW_LINE); 
     buffer.append(" Date : " +rssMsg.getDate()); 
     buffer.append(NEW_LINE); 
     buffer.append(" Time : " +rssMsg.getTime()); 
     buffer.append(NEW_LINE); 
     if(rssMsg.getEventResult() == null){ 
      buffer.append(" EventResult : Unavailable"); 
     }else{ 
     buffer.append(" EventResult : " +rssMsg.getEventResult()); 
     } 
     buffer.append(NEW_LINE); 
     buffer.append(" DateRevised : " +rssMsg.getDateRevised()); 
     buffer.append(NEW_LINE); 
     buffer.append(" EventType : " +rssMsg.getEventType()); 
     buffer.append(NEW_LINE); 
     buffer.append(" Location : " +rssMsg.getLocation()); 
     buffer.append(NEW_LINE); 
     buffer.append(NEW_LINE); 
    } 
    textView.setTextColor(Color.parseColor("#FFDD00")); 
    textView.setBackgroundColor(Color.parseColor("#003767")); 
    textView.setText(Html.fromHtml(buffer.toString())); 
} 
+0

으로 업로드하십시오.이 코드를 입력해야하고 어디에서보아야할까요? –

+0

그럼 어떻게 분배기를 설정하겠습니까? –

+0

분배기는 무엇을 의미합니까? 무엇 사이? – Kelevandos

관련 문제