5

Ich kann nicht verstehen, warum das passiert. Ich kann meinen Bildlauf nicht durchblättern. Es hat eine Textansicht, eine Bildansicht und einige lineare Layouts darin. Wenn ich die Bildansicht und lineare Layouts durch Textansicht ersetze, funktioniert es. Das ist wirklich ungewöhnlich und frustrierend. Kann mir jemand helfen? Hier ist mein Code:ScrollView nicht Scrollen - Android

<LinearLayout 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" > 

<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:animateLayoutChanges="true" 
     android:orientation="vertical" 
     android:scrollbars="vertical" > 

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center" 
      android:text="Drop Text Down" 
      android:textAppearance="?android:attr/textAppearanceLarge" /> 

     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="match_parent" 
      android:layout_height="555dp" 
      android:src="@drawable/ic_launcher" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/ln" 
      android:layout_width="match_parent" 
      android:layout_height="100dp" 
      android:background="#000000" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/TextView06" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/TextView05" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/TextView04" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/TextView03" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/TextView02" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/TextView01" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" /> 
      </LinearLayout> 

     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 

</LinearLayout> 

Danke.

+0

Versuchen Sie, die layout_height Ihrer Scroll Ändern –

+0

@Bidhan A bis wrap_content Ich habe das Layout Gewicht innerhalb des Scrollview zu verwenden. also kann ich die höhe nicht auf wrap_content setzen – David

+2

@David hast du eine lösung gefunden? –

Antwort

9

Die untergeordnete Ansicht eines ScrollView sollte auf wrap_content festgelegt werden. Wenn Sie es auf match_parent setzen, füllt es den Bereich ScrollView und scrollt nie, weil es nicht größer als ScrollView ist.

Versuchen Sie, das untergeordnete Element LinearLayout layout_height entweder auf wrap_content oder eine bestimmte Größe (in dp) anstelle von match_parent zu ändern.

+9

Nein ... funktioniert nicht – David

+0

Nop hilft nicht immer .. Dies ist nur eines der scheinbar mehrere Probleme mit diesem Element von ADT ... –

-4

Verwendung Tabellenlayout statt linear Layout etwas wie folgt aus:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" android:fadeScrollbars="false" android:padding="6dip"> 
<TableLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:stretchColumns="1" 
    > 
    //your stuff 
</TableLayout> 
</ScrollView> 
+0

Es gibt nichts mit linearem Layout oder Tabellenlayout zu tun – Ankit

2

Ihr ScrollView Kind braucht seine Höhe zu haben, wie wrap_content:

<ScrollView 
android:id="@+id/scrollView1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:animateLayoutChanges="true" 
    android:orientation="vertical" 
    android:scrollbars="vertical" > 

    ... 
    ... 
</LinearLayout> 
</ScrollView> 
+0

Versucht dies, aber es funktioniert nicht – David

1

Sie sollten die Höhe des Linearlayout festgelegt (Kind Scrollview) zu wrap_content.

Wenn das Kind größer als die ScrollView ist, dann hat das Attribut android: fillViewport = "true" keine Auswirkung.

+0

Ich weiß das. Aber ich möchte Layout-Gewicht für diese Layouts festlegen, also muss ich fillViewPort verwenden. – David

+0

@David können Sie versuchen, android: layout_height = "wrap_content" für die Bildansicht mit ID = "imageView1" – Vikas

-1
<ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" > 

Remove android: fillViewport = "true" von oben Element

+0

Nop, ich habe viele scrollViews und einige von ihnen arbeiten, nicht, invariant auf diesem Parameter. –

0

ich hatte das gleiche Problem und ich schaffte es, indem Sie den folgenden Code in dem Kofferraum meines Fragment zu lösen

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
3

Legen Sie eine leere Ansicht mit fester Höhe

<View 
       android:layout_width="match_parent" 
       android:layout_height="50dp" /> 

als letztes Element in dem linearen Layout, das ist ein Kind Scroll-Ansicht ..

Dieser arbeitete für mich ..

+1

Genie! Vielen Dank. – zackygaurav

+1

Froh, dass es dir geholfen hat .. –

Verwandte Themen