Android ScrollView无法正常工作,尝试了所有答案

时间:2017-06-16 13:17:15

标签: android android-layout listview scroll

我是Android开发的新手,我有很多内容,但滚动完全没有在我的应用程序上工作,尝试使用stackoverflow中的所有答案,但没有任何对我有用。 任何帮助将不胜感激!

<?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>

2 个答案:

答案 0 :(得分:1)

NestedScrollView而不是Scrollview应该可以解决您的问题。 在一个完全不同的主题,因为你现在开始使用android develpment,我建议你学习/使用RecycleView而不是ListView。 RecycleView更易于实现,具有出色的后向兼容性,并且不需要“视图持有者模式”以提高性能。 这是一个可以帮助您掌握一些基本概念的链接:

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

答案 1 :(得分:0)

尝试使用NestedScrollView,问题可能是你在scrollview中有一个listview。

相关问题