2016-06-20 12 views
-3

Ich habe eine Android-Quiz-App erstellt, die eine ScrollView hat. Das Problem ist, wenn Sie nach unten scrollen, geht es automatisch zurück, so dass Benutzer die Antwort nicht unten auswählen können. Wie behebe ich das?android scroll view gibt mir Probleme

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/relatively" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/add" 
    android:orientation="vertical" 
    android:weightSum="1" > 

    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="292dp" 
     android:id="@+id/scrollView" 
     android:layout_gravity="center_horizontal" 
     android:layout_weight="0.20"> 

     <LinearLayout 
      android:id="@+id/linearLayout1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0.90" 
      android:orientation="vertical" 
      android:weightSum="1" > 

      <LinearLayout 
       android:id="@+id/linearLayout11" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.20" 
       android:orientation="horizontal" 
       android:weightSum="1" > 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:orientation="horizontal" > 

        <TextView 
         android:id="@+id/score" 
         android:layout_width="160dp" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:layout_marginRight="10dp" 
         android:gravity="center" 
         android:text="Maraga : 0" 
         android:textColor="#bc42f4" 
         android:textSize="25.0sp" 
         android:textStyle="bold" /> 

        <TextView 
         android:id="@+id/timers" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:layout_marginRight="10dp" 
         android:layout_weight="1" 
         android:gravity="center" 
         android:text="00:00:49" 
         android:textColor="#ab0afb" 
         android:textSize="25.0sp" 
         android:textStyle="bold" 
         android:textIsSelectable="true" /> 
       </LinearLayout> 
      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/linearLayout12" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight=".8" 
       android:orientation="vertical" 
       android:weightSum="1" > 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_weight="0.40" > 

        <TextView 
         android:id="@+id/txtQuestion" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_centerHorizontal="true" 
         android:layout_gravity="center" 
         android:layout_marginTop="5dp" 
         android:gravity="center" 
         android:text="15*2*1-1" 
         android:textColor="#fd0213" 
         android:textSize="35.0sp" 
         android:textStyle="bold" /> 
       </LinearLayout> 

       <LinearLayout 
        android:layout_width="295dp" 
        android:layout_height="381dp" 
        android:orientation="vertical" 
        android:weightSum="1" 
        android:gravity="fill_horizontal|start|end|center_horizontal" 
        android:layout_gravity="center_horizontal"> 

        <Button 
         android:id="@+id/button1" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_marginTop="20dp" 
         android:background="#09bcf8" 
         android:gravity="center" 
         android:text="30" 
         android:textColor="#ffffff" 
         android:textSize="25.0sp" /> 

        <Button 
         android:id="@+id/button2" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_marginTop="20dp" 
         android:background="#2cf309" 
         android:gravity="center" 
         android:text="29" 
         android:textColor="#ffffff" 
         android:textSize="25.0sp" /> 

        <Button 
         android:id="@+id/button3" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_marginTop="20dp" 
         android:background="#7f0af4" 
         android:gravity="center" 
         android:text="32" 
         android:textColor="#ffffff" 
         android:textSize="25.0sp" /> 

       </LinearLayout> 


      </LinearLayout> 


     </LinearLayout> 
    </ScrollView> 

    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     ads:adSize="SMART_BANNER" 

     ads:adUnitId="@string/banner_ad_unit_id" 
     android:layout_weight="1.5" 
     android:transitionGroup="false"> 
    </com.google.android.gms.ads.AdView> 


</LinearLayout> 
+0

ich denke, Sie schreiben falsche Eigenschaften. –

+0

kannst du bitte zeigen was genau zu tun ist. Die erste Sache ist, dass fillViewport = true in scrollview –

+0

hinzufügen scrollView Höhe zu 'wrap_content' ändern. !! –

Antwort

0

Entfernen Sie diese Zeile: android: layout_weight = "0.20" in Ihrem Scroll.

0

diesen Code versuche ich so viele Dinge in Ihrem Code

Sie genommen so viele unnötige Layouts geändert wurde. Stellen Sie sicher, dass Sie das nächste Mal eine Ansicht mit weniger Layout erstellen. weil es sich auf Grafiken lastet.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/scrollView" 
    android:orientation="vertical" 
    android:fillViewport="true" 
    android:layout_gravity="center_horizontal"> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:weightSum="1" 
     > 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:paddingLeft="30dp" 
      android:paddingRight="30dp" 
      android:layout_weight="0.80" 
      android:orientation="vertical"> 

     <LinearLayout 
      android:id="@+id/linearLayout11" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:weightSum="1" 
      android:orientation="horizontal"> 
       <TextView 
        android:id="@+id/score" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:text="Maraga : 0" 
        android:layout_weight="0.5" 
        android:textColor="#bc42f4" 
        android:textSize="25.0sp" 
        android:textStyle="bold" /> 

       <TextView 
        android:id="@+id/timers" 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_marginRight="10dp" 
        android:layout_weight="0.5" 
        android:gravity="center" 
        android:text="00:00:49" 
        android:textColor="#ab0afb" 
        android:textSize="25.0sp" 
        android:textStyle="bold" 
        android:textIsSelectable="true" /> 
      </LinearLayout> 


       <TextView 
        android:id="@+id/txtQuestion" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="5dp" 
        android:gravity="center" 
        android:text="15*2*1-1" 
        android:textColor="#fd0213" 
        android:textSize="35.0sp" 
        android:textStyle="bold" /> 


       <Button 
        android:id="@+id/button1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="20dp" 
        android:background="#09bcf8" 
        android:gravity="center" 
        android:text="30" 
        android:textColor="#ffffff" 
        android:textSize="25.0sp" /> 

       <Button 
        android:id="@+id/button2" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="20dp" 
        android:background="#2cf309" 
        android:gravity="center" 
        android:text="29" 
        android:textColor="#ffffff" 
        android:textSize="25.0sp" /> 

       <Button 
        android:id="@+id/button3" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:layout_marginTop="20dp" 
        android:background="#7f0af4" 
        android:gravity="center" 
        android:text="32" 
        android:textColor="#ffffff" 
        android:textSize="25.0sp" /> 


     </LinearLayout> 
     <com.google.android.gms.ads.AdView 
      android:id="@+id/adView" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      ads:adSize="SMART_BANNER" 
      ads:adUnitId="@string/banner_ad_unit_id" 
      android:layout_weight="0.20" 
      android:transitionGroup="false"> 
     </com.google.android.gms.ads.AdView> 
    </LinearLayout> 


</ScrollView>