2011-03-15 4 views
5

필자는 HorizontalScrollView에서 fillviewport = true를 사용하지 않으면 위와 같은 레이아웃을 가지고 있으며, 그 레이아웃이 이상하게 (아마 부적절한 레이아웃 중첩 때문에) 축소됩니다.horizontalalscrollview의 fillviewport가 스크롤을 사용 중지합니까?

fillviewport = false 인 경우 모든 것이 복숭아 (홀수 배율 제외)로 작동하지만 fillviewport = true 인 경우 배율은 완벽하지만 스크롤이 발생하지 않습니다.

:

레이아웃 (.. 나는 당신이있는 ScrollView에 웹뷰를 넣어 안 거 알아하지만 웹보기가 setscroller의 메소드를 smoothscrollto이도 노출하지 않습니다, 그래서 ... bleh 주)입니다
<?xml version="1.0" encoding="utf-8"?> 
<HorizontalScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/webContainer" 
    android:layout_below="@+id/titlebar" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true"> 
    <WebView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webZ" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
    /> 
</HorizontalScrollView> 

android : fillViewport = "true"로 설정하면 대개보기에서 스크롤이 비활성화되지 않습니까? 그렇습니다.

스크롤 뷰가 내용의 크기에 관계없이 뷰포트를 채우고 있는지 확인해야합니다. 뷰포트가 화면의 보이는 영역이라고 생각하고 웹 뷰의 보이는 영역 가장자리에서 더 많은 내용이 분명히 있습니다. 더 이상 스크롤 할 수 없습니다.

나는 logcat에서 스크롤 방법이 호출되는 것을 볼 수 있습니다. 단지 화면을 변경하지 않습니다. (fillviewport를 false로 설정하지 않은 경우)

+0

을, 당신은'WebView'의 콘텐츠하지만'WebView' 내가 스크롤되지 않을 것이다 tself. 나는 네가 다른 쪽을 감싸는 것에 조심해야한다고 생각한다. –

+1

나는 이것을위한 또 다른 방법을 찾고 싶지만, 내 인생은 WebView에 내장 된 메서드를 사용하여 부드러운 수평 스크롤을 얻을 수 없다.: 내 프로젝트의 요점은 HTML을 표시하는 것이기 때문에 실제로 의미가있는 다른보기도 없다. – Turnsole

답변

4

"fill_parent"는 "부모님만큼 크게"라는 의미입니다. 대신 너비에 wrap_content를 사용하십시오.

+0

와우. 나는 그것을 놓쳤다.하지만 고마워! – Turnsole

2

WebView가 포함 된 표준 ScrollView에서 비슷한 문제가 발생합니다. 스크롤이 더 이상 작동하지 않습니다. fill_parent를 wrap_content로 변경해도 효과가 없습니다.

Romain Guy의 예제는 확장 된 뷰가 TextView이지만 WebView로 대체 될 때 잘 동작하지 않습니다.

무엇을 작동하지 않는 : 나는 웹보기에 적은 양의 데이터를 추가 할 때

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <WebView android:id="@+id/webview" 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:layout_weight="1.0"> 
     </WebView> 
     <Button 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:text="Click"> 
     </Button> 
    </LinearLayout>  
</ScrollView> 

는 괜찮아 보인다

small_data_not_ok1

을하지만이 많은 웹보기를 채울 때 데이터가 아니라면 아래에서 볼 수있는 것처럼 작동하지 않습니다.

small_data_not_ok2

버튼이 항상 표시되고 스크롤이 더 이상 작동하지 않습니다. 사실, 터치 스크롤이 작동하지 않고 DPAD 스크롤

내가 그것에 대해 어떤 이유를 발견하지 않았다하지만 해결 방법을 발견 ... 작동 : 그것은 웹보기

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:fillViewport="true"> 
    <LinearLayout 
     android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:orientation="vertical"> 
     <LinearLayout android:id="@+id/linearlayout" 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:layout_weight="1.0" 
      android:orientation="vertical"> 
      <WebView android:id="@+id/webview" 
       android:layout_width="fill_parent" android:layout_height="wrap_content"> 
      </WebView> 
     </LinearLayout> 
     <Button 
      android:layout_width="fill_parent" android:layout_height="wrap_content" 
      android:text="Click"> 
     </Button> 
    </LinearLayout>  
</ScrollView> 
을 포함하는있는 LinearLayout을 추가로 구성

지금 그것을 잘 작동합니다 : 당신은`HorizontalScrollView`에 scrollTo의 방법을 사용하더라도

ok1 ok2

관련 문제