2017-06-16 64 views
0

是新的android開發,我有很多內容,但滾動並沒有在我的應用程序工作,嘗試所有在stackoverflow中的答案,但沒有爲我工作。 任何幫助將不勝感激!Android ScrollView是不工作,嘗試所有的答案

<?xml version="1.0" encoding="utf-8"?> 
 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
 
    android:id="@+id/ScrollView01" 
 
    android:layout_width="match_parent" 
 
    android:layout_height="match_parent" 
 
    android:fillViewport="true" 
 
    android:scrollbars="none" > 
 

 

 
    <RelativeLayout 
 
      android:layout_width="match_parent" 
 
      android:layout_height="wrap_content" 
 
      android:id="@+id/scoreview" 
 

 
      android:background="@android:color/black" 
 
      xmlns:tools="http://schemas.android.com/tools" 
 
      tools:context="com.example.saikumar.cricket.ScoreDisplay" 
 
      > 
 
      <RelativeLayout 
 
       android:id="@+id/loadingPanel" 
 
       android:layout_width="match_parent" 
 
       android:layout_height="match_parent" 
 
       android:gravity="center" > 
 
       <ProgressBar 
 
        android:layout_width="wrap_content" 
 
        android:layout_height="wrap_content" 
 
        android:indeterminate="true" /> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/matchtitle_layout"> 
 
       <Button 
 
        android:id="@+id/match_title" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:gravity="center" 
 
        android:padding="10dp" 
 
        android:text="Loading..." 
 
        android:fontFamily="monospace" 
 
        android:textColor="@android:color/white" 
 
        android:textSize="13dp" 
 
        android:clickable="false" 
 
        android:background="@color/colorPrimary" 
 
        /> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/score_layout" 
 
       android:visibility="gone" 
 
       android:layout_below="@+id/matchtitle_layout" 
 
       > 
 
       <LinearLayout 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        > 
 
        <TextView 
 
         android:id="@+id/score" 
 
         android:layout_width="wrap_content" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="Score" 
 
         android:padding="10dp" 
 
         android:textColor="@android:color/white" 
 
         android:textSize="15dp" 
 
         android:fontFamily="monospace" 
 
         android:textStyle="bold" 
 
         /> 
 
        <TextView 
 
         android:id="@+id/scoreruns" 
 
         android:layout_width="wrap_content" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="3" 
 
         android:text="Score" 
 
         android:fontFamily="monospace" 
 
         android:padding="10dp" 
 
         android:paddingLeft="0dp" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         android:layout_below="@+id/match_title" 
 
         android:layout_alignEnd="@+id/overscount" /> 
 
       </LinearLayout> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:layout_below="@+id/score_layout" 
 
       android:id="@+id/bowler_layout" 
 
       android:visibility="gone" 
 
       > 
 
       <LinearLayout 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content"> 
 
        <TextView 
 
         android:id="@+id/bowler" 
 
         android:layout_width="wrap_content" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="Bowler" 
 
         android:padding="10dp" 
 
         android:textColor="@android:color/white" 
 
         android:textSize="15dp" 
 
         android:fontFamily="monospace" 
 
         android:textStyle="bold" 
 
         /> 
 
        <TextView 
 
         android:id="@+id/bowlername" 
 
         android:layout_width="wrap_content" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="3" 
 
         android:text="Name" 
 
         android:fontFamily="monospace" 
 
         android:padding="10dp" 
 
         android:paddingLeft="0dp" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         android:layout_below="@+id/match_title" 
 
         android:layout_alignEnd="@+id/overscount" /> 
 
       </LinearLayout> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/innings" 
 
       android:layout_below="@+id/bowler_layout" 
 
       > 
 
       <TextView 
 
        android:id="@+id/total" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:layout_weight="1" 
 
        android:text="Loading..." 
 
        android:padding="20dp" 
 
        android:fontFamily="monospace" 
 
        android:textSize="15dp" 
 
        android:textColor="@android:color/white" 
 
        /> 
 
      </RelativeLayout> 
 

 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:layout_below="@+id/innings" 
 
       android:id="@+id/heading_innings" 
 
       > 
 
       <LinearLayout 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:background="@android:color/holo_red_light" 
 
        android:padding="10dip" 
 
        > 
 
        <TextView 
 
         android:id="@+id/batsman" 
 
         android:layout_width="140dp" 
 
         android:layout_height="wrap_content" 
 
         android:text="BatsMan" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="R" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="B" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="4s" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="6s" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="SR" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
       </LinearLayout> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/batting_reltive_layout_one" 
 
       android:layout_below="@+id/heading_innings" 
 
       > 
 
       <ListView 
 
        android:id="@+id/batting_runs" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        tools:layout_editor_absoluteX="8dp" 
 
        tools:layout_editor_absoluteY="8dp" 
 
        android:padding="1dp"/> 
 
      </RelativeLayout> 
 

 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/inningstwo" 
 
       android:layout_below="@+id/batting_reltive_layout_one" 
 
       > 
 
       <TextView 
 
        android:id="@+id/totalsecond" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:layout_weight="1" 
 
        android:text="Loading..." 
 
        android:padding="20dp" 
 
        android:fontFamily="monospace" 
 
        android:textSize="15dp" 
 
        android:textColor="@android:color/white" 
 
        /> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:layout_below="@+id/inningstwo" 
 
       android:id="@+id/heading_innings_two" 
 
       > 
 
       <LinearLayout 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        android:background="@android:color/holo_red_light" 
 
        android:padding="10dip" 
 
        > 
 

 
        <TextView 
 
         android:layout_width="140dp" 
 
         android:layout_height="wrap_content" 
 
         android:text="BatsMan" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="R" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="B" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="4s" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="6s" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
        <TextView 
 
         android:layout_width="match_parent" 
 
         android:layout_height="wrap_content" 
 
         android:layout_weight="1" 
 
         android:text="SR" 
 
         android:fontFamily="monospace" 
 
         android:textSize="15dp" 
 
         android:textColor="@android:color/white" 
 
         /> 
 
       </LinearLayout> 
 
      </RelativeLayout> 
 
      <RelativeLayout 
 
       android:layout_width="match_parent" 
 
       android:layout_height="wrap_content" 
 
       android:id="@+id/batting_reltive_layout_two" 
 
       android:layout_below="@+id/heading_innings_two" 
 
       > 
 
       <ListView 
 
        android:isScrollContainer="false" 
 
        android:id="@+id/batting_runs_two" 
 
        android:layout_width="match_parent" 
 
        android:layout_height="wrap_content" 
 
        tools:layout_editor_absoluteX="8dp" 
 
        tools:layout_editor_absoluteY="8dp" 
 
        android:padding="1dp"/> 
 
      </RelativeLayout> 
 

 
     </RelativeLayout> 
 

 

 
</ScrollView>

+1

.. – sai

+1

的問題是內滾動視圖列表視圖。 https://stackoverflow.com/questions/18367522/android-list-view-inside-a-scroll-view –

回答

0

嘗試用NestedScrollView,問題是你有一個列表視圖,滾動型。

1

NestedScrollView而不是滾動視圖應該可以解決您的問題。 在完全不同的主題上,既然你現在開始使用android develpment,我建議你學習/使用RecycleView而不是ListView。 RecycleView更容易實現,具有出色的逆向兼容性,並且不需要「查看模式」以提高性能。 這裏是一個鏈接,可以幫助您掌握一些基本的概念:在這裏面臨着同樣的問題

https://guides.codepath.com/android/using-the-recyclerview