2016-12-22 3 views
0

나는 안드로이드 프로그래밍에 익숙하다. 간단한 계산기를 구현할 때 가로 스크롤보기 문제가 있습니다. 가로 스크롤보기 내에서 편집 텍스트를 사용하고 있습니다. 그것은 처음에는 완전히 정상적으로 작동하지만 화면을 지우 자마자 스크롤 한계를 유지합니다. 즉, 화면에 숫자가 적더라도 스크롤 할 수 있습니다. 내가 원하는 것은 그것의 스크롤을 제한하는 것입니다. 아래는 스크린 샷과 XML 코드입니다. 가로 스크롤보기, 스크롤 문제 Android

First Time

[제 시간] [2]

It is still scroll-able even though there are few digits

<HorizontalScrollView 
     android:id="@+id/hsvMain" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end" 
     android:scrollbars="none" 
    > 

     <EditText 

      android:id="@+id/mainEditText" 
      android:paddingTop="10dp" 
      android:paddingRight="2dp" 
      android:background="#ffff" 
      android:ellipsize="end" 
      android:focusable="false" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="55sp" 

      android:textStyle="bold" 

      /> 

    </HorizontalScrollView> 
+0

edittext layout_width @ height to wrap_content –

답변

0

레이아웃 높이/폭 특성 둘레 변경 시도 HorizontalScrollViewlayout_width="fill_parent"EditTextlayout_width="wrap_content"layout_height="wrap_content"

<HorizontalScrollView 
     android:id="@+id/hsvMain" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="end" 
     android:scrollbars="none"> 

     <EditText 
      android:id="@+id/mainEditText" 
      android:paddingTop="10dp" 
      android:paddingRight="2dp" 
      android:background="#ffff" 
      android:ellipsize="end" 
      android:focusable="false" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textSize="55sp" 
      android:textStyle="bold"/> 

</HorizontalScrollView> 

편집 :

당신이 EditText의 크기에 관계없이 내용을 포장하기 위해 scrollview를 이야기했기 때문에 이전에 작동하지 않는 이유 이유, 그래서 그것은 단지 EditText 스크롤 할 것입니다. 그러나 ScrollViewmatch_parent이라고 말하면 화면의 너비가 항상 같을 것이고 EditText는 크기에 관계없이 부모 (ScrollView) 내에서 스크롤 할 수 있습니다.

: match_parent 대신 fill_parent, fill_parent을 사용하여 지금은 사용되지 않습니다. (여전히 작동 함에도 불구하고)

+0

으로 고치십시오. 감사합니다. :) 왜 그것이 트릭을했고 왜 이전에 잘못 되었습니까? 다시 한번 감사드립니다. –

+0

도와 줘서 고맙습니다. –