2012-12-31 2 views
1

내 TextView에 문제가 있습니다.TextView 내 모든 텍스트를 보는 방법

내 텍스트보기 안의 텍스트가 너무 길면 내 전화에서 스크롤 할 수 없기 때문에 더 이상 볼 수 없습니다.

내 코드는 다음과 같습니다

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/lightgray" 
     tools:context=".BucketItemDescActivity" > 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/imageView1" 
      android:layout_marginLeft="25dp" 
      android:layout_marginRight="25dp" 
      android:layout_marginTop="19dp" 
      android:text="The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando) 
The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando)." 
      android:textSize="12sp" /> 

     <LinearLayout 
      android:id="@+id/frameLayout1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:background="#336699" > 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="10dp" 
       android:layout_marginLeft="25dp" 
       android:textSize="15sp" 
       android:textColor="#FFFFFF" 
       android:text="The Godfather (1972)" /> 

     </LinearLayout> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/frameLayout1" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="18dp" 
      android:src="@drawable/movie1" /> 

    </RelativeLayout> 

어떻게이 문제를 해결할 수 있습니까?

ScrollView 안에 당신에게

답변

1

yourTextView에있는 ScrollView 추가

<ScrollView android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/imageView1" 
      android:layout_marginLeft="25dp" 
      android:layout_marginRight="25dp" 
      android:layout_marginTop="19dp" 
      android:scrollbars="none"> 
     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando) 
The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando)." 
      android:textSize="12sp" /> 

</ScrollView> 

편집

있는 ScrollView 안에 이미지 뷰를 추가하려면,이 곳에서 이미지 뷰를 제거하고 추가 이렇게하면

<ScrollView android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
      android:layout_below="@+id/imageView1" 
      android:layout_marginLeft="25dp" 
      android:layout_marginRight="25dp" 
      android:layout_marginTop="19dp" 
      android:scrollbars="none"> 

    <LinearLayout android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

      <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="18dp" 
      android:src="@drawable/ic_launcher" /> 

     <TextView 
      android:id="@+id/textView3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando) 
The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando)." 
      android:textSize="12sp" /> 
     </LinearLayout> 
</ScrollView> 
당신의 TextView

설정이 :

android:maxLines = "AN_INTEGER"  
android:scrollbars = "vertical" 

을 다음 Activity에서이를 사용

+0

감사합니다. :)하지만 스크롤바는 추합니다. – newbie

+0

scrollview android : scrollbars = "none"에 이것을 추가하십시오. 스크롤 막대를 숨길 것입니다. –

+0

어떻게 스크롤 뷰 내부에 이미지를 포함시킬 수 있습니까? 아이 한 명만 추가 할 수 있다는 오류가 있습니다 – newbie

2

장소의 모든 의견을 주셔서 감사합니다.

예를 들어

:

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/lightgray" 
     tools:context=".BucketItemDescActivity"> 

    <ScrollView> 
    <TextView/> 
    <TextView/> 
    .......... 
    .......... 
    .......... 

    </ScrollView> 
</RelativeLayout> 
1
<ScrollView ... > 
    <TextView fill_parent etc./> 





</ScrollView> 
1

이 시도

yourTextView.setMovementMethod(new ScrollingMovementMethod()); 

감사합니다.

2

코드 대신 아래 XML 코드를 사용하면 문제가 해결됩니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/lightgray" > 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" > 

      <TextView 
       android:id="@+id/textView3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@+id/imageView1" 
       android:layout_marginLeft="25dp" 
       android:layout_marginRight="25dp" 
       android:layout_marginTop="19dp" 
       android:text="The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando) 
The Godfather is a 1972 American epic crime film directed by Francis Ford Coppola and produced by Albert S. Ruddy from a screenplay by Mario Puzo and Coppola. Based on Puzo&apos;s 1969 novel of the same name, the film stars Marlon Brando and Al Pacino as the leaders of a powerful New York crime family. The story, spanning the years 1945 to 1955, centers on the ascension of Michael Corleone (Pacino) from reluctant family outsider to ruthless Mafia boss while also chronicling the Corleone family under the patriarch Vito Corleone (Brando)." 
       android:textSize="12sp" /> 

      <LinearLayout 
       android:id="@+id/frameLayout1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentTop="true" 
       android:background="#336699" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_margin="10dp" 
        android:layout_marginLeft="25dp" 
        android:text="The Godfather (1972)" 
        android:textColor="#FFFFFF" 
        android:textSize="15sp" /> 
      </LinearLayout> 

      <ImageView 
       android:id="@+id/imageView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/frameLayout1" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="18dp" 
       android:src="@drawable/movie1" /> 
     </RelativeLayout> 
    </ScrollView> 

</RelativeLayout> 
관련 문제