2016-04-22 11 views
1

Ich versuche, mich Layout nach unten scrollen lassen. Ich habe einige Posts mit diesem Thema gesehen und ich habe versucht, das zu tun, was sie erklärt haben, aber es hat nicht funktioniert. Dies ist, was ich jetzt habe, und jetzt wird mein Projekt nicht einmal starten, wahrscheinlich weil es fehlplatziert ist. DieseHinzufügen von Scrollview in Android Projekt Layout

ist, wie mein Code wie folgt aussieht:

<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" 
    android:orientation="vertical" 
    tools:context="com.example.rodekruis.Bezoek" > 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="right" 
     android:layout_marginBottom="20dp" 
     android:src="@drawable/rkz_logo" /> 


    <ScrollView 
    android:id="@+id/scrollview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 



    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="244dp" 
     android:layout_height="276dp" 
     android:layout_gravity="center" 
     android:text="@string/title_activity_contact" 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="@color/black" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="244dp" 
     android:layout_height="42dp" 
     android:layout_gravity="center" 
     android:layout_weight="0.39" 
     android:text="Klik hier voor de uitgebreide contactgegevens." 
     android:textAppearance="?android:attr/textAppearanceSmall" 
     android:textColor="@color/black" /> 
    </ScrollView> 
</LinearLayout> 
+2

Scroll nur ein Kind hat, die eine Ansicht Gruppe sein kann –

Antwort

0

ScrollView kann nur hat ein Kind, so dass Sie einen Layout Manager hinzufügen sollten, die alle Layouts in ScrollView wickeln.

<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" 
    android:orientation="vertical" 
    tools:context="com.example.rodekruis.Bezoek" > 
    ... 
    <ScrollView 
    android:id="@+id/scrollview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 

    <TextView 
     android:id="@+id/textView1" 
     .../> 

    <TextView 
     android:id="@+id/textView2" 
     .../> 

    </LinearLayout> 
    </ScrollView> 
    ... 

+0

Dieser gesamte Code gibt mir den Fehler: XML-Dokument muss mit derselben Entität beginnen und enden –

+0

@SneakyAndStuff haben Sie 'LinearLayout' -Tag geschlossen. Stellen Sie sicher, dass Sie das xml-Tag korrekt öffnen und schließen. –

+0

Hat das, das die Anwendung starten kann, immer noch nicht in der Lage, nach unten zu scrollen. –

0

Scroll ein nur ein Kind hat und Ihr layuot zwei Kind mit, verwenden Sie diese spinets

<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" 
android:orientation="vertical"> 

<ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="right" 
    android:layout_marginBottom="20dp" /> 


<ScrollView 
    android:id="@+id/scrollview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

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

     <TextView 
      android:id="@+id/textView1" 
      android:layout_width="244dp" 
      android:layout_height="276dp" 
      android:layout_gravity="center" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="@color/black" /> 

     <TextView 
      android:id="@+id/textView2" 
      android:layout_width="244dp" 
      android:layout_height="42dp" 
      android:layout_gravity="center" 
      android:layout_weight="0.39" 
      android:text="Klik hier voor de uitgebreide contactgegevens." 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textColor="@color/black" /> 
    </LinearLayout> 


</ScrollView> 

+0

hinzugefügt Dieser ganze Code gibt mir den Fehler: XML-Dokument muss mit der gleichen Entität beginnen und enden –

+0

zuletzt Karthik

+0

in der Anzeige zeigen wir nicht Abschluss-Tag von LinearLayout, sollten Sie add unten von –

Verwandte Themen