5

Non riesco a capire perché questo sta accadendo. Non riesco a scorrere la mia scrollview. Ha una textView, una imageview e pochi layout lineari al suo interno. Quando sostituisco la visualizzazione di immagini e i layout lineari con textview, funziona. Questo è davvero insolito e frustrante. Qualcuno può aiutarmi? Ecco il mio codice:ScrollView not Scrolling - 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> 

Grazie.

+0

provare a cambiare la layout_height del ScrollView per wrap_content –

+0

@Bidhan Un devo usare il peso di layout all'interno del ScrollView. quindi non posso impostare l'altezza di wrap_content – David

+2

@David hai trovato una soluzione a questo? –

risposta

9

La vista secondaria di un ScrollView deve essere impostata su wrap_content. Se lo si imposta su match_parent, riempirà l'area di ScrollView e non scorrerà mai, poiché non sarà più grande di ScrollView.

Provare a cambiare il bambino LinearLayout layout_height su wrap_content o su una dimensione specifica (in dp) invece di match_parent.

+9

No ... Non funziona – David

+0

Nop non aiuta sempre .. Questo è solo uno dei problemi apparentemente diversi con questo elemento di ADT ... –

-4

uso Tabella layout invece di aspetto di qualcosa di lineare come questo:

<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

non c'è nulla a che fare con il layout lineare o il layout di tabella – Ankit

2

tuo ScrollView bambino ha bisogno di avere la sua altezza come 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

Provato questo, ma non funziona – David

1

È necessario impostare l'altezza del LinearLayout (figlio di Scrollview) per wrap_content.

Quando il bambino è più alto di ScrollView, quindi android: fillViewport = l'attributo "true" non ha alcun effetto.

+0

Lo so. Ma voglio impostare il peso del layout per questi layout, quindi devo usare fillViewPort. – David

+0

@David potrebbe essere possibile provare Android: layout_height = "wrap_content" per l'imageview con id = "imageView1" – Vikas

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

Rimuovere android: fillViewport = "true" da elemento sopra

+0

Nop, ho molte scrollView e alcune funzionano, non lo sono, invariabilmente su questo parametro. –

0

Ho avuto lo stesso problema e sono riuscito a risolvere inserendo il seguente codice nel bagagliaio della mia frammento

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

Metti una vista vuota ad altezza fissa

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

come il tuo ultimo articolo nel layout lineare che è un figlio di vista di scorrimento ..

questo ha lavorato per me ..

+1

Genius! Grazie. – zackygaurav

+1

Felice che ti abbia aiutato .. –

Problemi correlati