2014-01-30 4 views

답변

0

아마도 포커스 속성이 누락되어 Textview에 포커스가 없으므로 스크롤되지 않습니다.

<TextView 
    android:id="@+id/title_itemcount" 
    android:layout_width="0dp" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:maxLines="3" 
    android:padding="4dp" 
    android:scrollbars="vertical" 
    android:textColor="@android:color/background_dark" /> 

은 당신이 ScrollViewTextView을 배치해야한다 "부드러운 스크롤"을 원하는 경우 :

+0

포커스 특성 도움 안됨 :( – MilapTank

0

문제는 ... 희망이 도움이. 그리고 그렇게하면 더 이상 의 TextView 높이를 "match_parent"로 설정할 수 없습니다. 예를 들어, 텍스트로 동적으로 채워지는 큰 TextBox가 필요한 경우, 과 같이 크기가 조절되지는 않습니다. 그리고 ScrollView의 속성을 "match_parent"로 설정하면 자식 TextView이 콘텐츠를 계속 둘러 쌉니다.

나는 이런 식으로 일을 할 수 있었다 :

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:drawable/edit_text"> 

    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@null" 
      android:gravity="bottom" 
      android:singleLine="false" 
      android:typeface="serif"/> 
    </ScrollView> 
</RelativeLayout> 

원하는 배경으로, 새로운 TextView로 역할을하는 RelativeLayout 용기, null로 설정 배경 원래 TextView. TextView 이 확장되어 새로운 텍스트가 추가되면 텍스트 볼륨이 증가하는 것과 같습니다. ScrollView 인 경우 텍스트가 레이아웃 속성과 정렬됩니다.

특정 시나리오에서 ScrollView의 스크롤과의 충돌을 피하려면 TextView의 스크롤을 사용 중지해야 할 수도 있습니다.

관련 문제