2016-04-07 4 views
0

Quelqu'un peut-il me dire pourquoi ce ScrollView ne fonctionne pas? J'ai vérifié les autres réponses pour cette question et cela n'a pas résolu mon problème. Il a juste un enfant. Il a un support de fermeture. Des idées? Merci à l'avanceScrollView ne fera pas défiler la page

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView 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" 
    android:background="#89abe3" 
    tools:context=".GardaLoginActivity" > 

<RelativeLayout 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:focusableInTouchMode="true" android:fitsSystemWindows="true" 
    android:background="#89abe3"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Smart Neighborhood Watch" 
     android:id="@+id/Logo" 
     android:textSize="40dp" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="35dp" 
     android:textColor="#ffdd00" 
     android:textStyle="bold"/> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/Logo" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="17dp" > 

     <TextView 
      android:id="@+id/lblGardaEmail" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Email" 
      android:textColor="#FFFFFF"/> 

     </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearLayout1" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="17dp"> 

     <EditText 
      android:id="@+id/txtGardaEmail" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:inputType="textEmailAddress" 
      android:textColor="#FFFFFF"/> 
     <requestFocus /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout3" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearLayout2" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="17dp"> 

     <TextView 
      android:id="@+id/lblGardaPassword" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="@string/password" 
      android:textColor="#FFFFFF"/> 

     </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout4" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearLayout3" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="17dp"> 

     <EditText 
      android:id="@+id/txtGardaPassword" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:textColorHint="#cccccc" 
      android:hint="Minimum 7 characters" 
      android:inputType="textPassword" 
      android:textColor="#FFFFFF" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout5" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearLayout4" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="30dp" 
     android:gravity="center" 
     android:weightSum="1"> 

    <Button 
     android:id="@+id/btnGardaLogin" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/login" 
     android:background="#66c2ff" 
     android:textColor="#FFFFFF" 
     android:layout_weight="0.30" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/linearLayout6" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/linearLayout5" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="10dp" 
     android:gravity="center" 
     > 

    <TextView 
     android:id="@+id/textViewGardaRegister" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Not a member? Register" 
     android:paddingTop="10dp" 
     android:textColor="#FFFFFF" /> 
    </LinearLayout> 


</RelativeLayout> 

</ScrollView> 
+0

Pouvez-vous modifier android: layout_height = "wrap_content" pour RelativeLayout ?? –

+0

@Cian voir ma réponse ci-dessous. –

+0

J'ai essayé votre code. Scrollview fonctionne pour moi. – amalBit

Répondre

0

Note importante:

Selon les directives Android, Android: attribut layout_height de les premiers (et seulement) les enfants ScrollView doivent toujours être "wrap_content". Vous obtiendrez un avertissement de Lint si vous utilisez match_parent

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

avec ce code:

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true"> 
+0

Cela n'a pas fonctionné pour moi – Cian

+0

@Cian quelle erreur vous obtenez .. –

1

Désolé que je l'ai écrit cela comme une awnser que je ne peux pas commenter des questions. Si votre mise en page est plus grande que votre écran, le scrollview fonctionnera.

Et une chose disposition des enfants de ScrollView's hauteur wrap_content

<?xml version="1.0" encoding="utf-8"?> 
    <ScrollView 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" 
     android:background="#89abe3" 
     tools:context=".GardaLoginActivity" > 

    <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:focusableInTouchMode="true" 
      android:fitsSystemWindows="true" 
      android:background="#89abe3"> 
      //Your Code 
    </RelativeLayout> 

    </ScrollView> 
+0

Désolé. Cela n'a rien changé – Cian

+0

Cela a fonctionné pour moi ..... –

0

simplement changer votre enfant disposition par rapport à

<RelativeLayout 
    android:layout_width="match_parent" android:layout_height="match_parent" 
    android:focusableInTouchMode="true" 
    android:background="#89abe3"> 

que les dispositions relatives android:fitsSystemWindows="true" attribut utilise tout l'écran il n'y a pas de place pour ScrollView pour faire défiler.

0
<ScrollView 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" 
    android:background="#89abe3" 
    tools:context=".GardaLoginActivity" > 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#89abe3" 
     android:fitsSystemWindows="true" 
     android:focusableInTouchMode="true" > 

     <TextView 
      android:id="@+id/Logo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_gravity="center_horizontal" 
      android:layout_marginTop="35dp" 
      android:gravity="center" 
      android:text="Smart Neighborhood Watch" 
      android:textColor="#ffdd00" 
      android:textSize="40dp" 
      android:textStyle="bold" /> 

     <LinearLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/Logo" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <TextView 
       android:id="@+id/lblGardaEmail" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Email" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#FFFFFF" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout1" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/txtGardaEmail" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:inputType="textEmailAddress" 
       android:textColor="#FFFFFF" /> 

      <requestFocus /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout2" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <TextView 
       android:id="@+id/lblGardaPassword" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 

       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#FFFFFF" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout4" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout3" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/txtGardaPassword" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout5" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout4" 
      android:layout_centerHorizontal="true" 
      android:gravity="center" 
      android:paddingTop="30dp" 
      android:weightSum="1" > 

      <Button 
       android:id="@+id/btnGardaLogin" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.30" 
       android:background="#66c2ff" 

       android:textColor="#FFFFFF" /> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/linearLayout6" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout5" 
      android:layout_centerHorizontal="true" 
      android:gravity="center" 
      android:paddingTop="10dp" > 

      <TextView 
       android:id="@+id/textViewGardaRegister" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingTop="10dp" 
       android:text="Not a member? Register" 
       android:textAppearance="?android:attr/textAppearanceMedium" 
       android:textColor="#FFFFFF" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout7" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout6" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout8" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout7" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout9" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout8" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout10" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout9" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout11" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout10" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout12" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout11" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout13" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout12" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout14" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout13" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout15" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout14" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
     <LinearLayout 
      android:id="@+id/linearLayout16" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout15" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       android:textColorHint="#cccccc" /> 
     </LinearLayout> 
      <LinearLayout 
      android:id="@+id/linearLayout17" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/linearLayout16" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="17dp" > 

      <EditText 
       android:id="@+id/edt1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:hint="Minimum 7 characters" 
       android:inputType="textPassword" 
       android:textColor="#FFFFFF" 
       /> 
     </LinearLayout> 
    </RelativeLayout> 
</ScrollView> 
+0

S'il vous plaît vérifier avec le code ci-dessus pour la démonstration. –

-1

J'ai vérifié votre code. Cela fonctionne parfaitement même avec le défilement. Avez-vous d'autres doutes?