Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Can';t在XML中实现Scrollview_Android_Xml_Android Layout_Uiscrollview_Android Xml - Fatal编程技术网

Android Can';t在XML中实现Scrollview

Android Can';t在XML中实现Scrollview,android,xml,android-layout,uiscrollview,android-xml,Android,Xml,Android Layout,Uiscrollview,Android Xml,为什么我不能在我的项目中显示scroll视图,当run在我的项目中看不到scrollview时,我是否将scrollview放得不太正确?如何放置Scrollview,以便项目中的所有项都可以从我的XML代码中获取Scrollview activity.xml 您的scrollview高度不应在wrap中定义,因为您希望它滚动。 此外,卷轴内部的线性部分应以其高度为单位进行包裹,并在其内部包含一些元素 建议如果您不介意使用线性符号: <RelativeLayout xmlns:androi

为什么我不能在我的项目中显示scroll视图,当run在我的项目中看不到scrollview时,我是否将scrollview放得不太正确?如何放置Scrollview,以便项目中的所有项都可以从我的XML代码中获取Scrollview

activity.xml
您的scrollview高度不应在wrap中定义,因为您希望它滚动。 此外,卷轴内部的线性部分应以其高度为单位进行包裹,并在其内部包含一些元素

建议如果您不介意使用线性符号:

<RelativeLayout 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:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="10dp" >

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

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

            <ImageView
                android:id="@+id/ivPosterImage"
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:adjustViewBounds="true"
                android:maxHeight="300dp"
                android:src="@drawable/large_movie_poster" />

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

                <TextView
                    android:id="@+id/tvTitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignTop="@+id/ivPosterImage"
                    android:layout_marginLeft="8dp"
                    android:layout_marginTop="5dp"
                    android:layout_toRightOf="@+id/ivPosterImage"
                    android:text="@string/movie_title"
                    android:textSize="18sp" />

                <TextView
                    android:id="@+id/tvCriticsScore"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/tvTitle"
                    android:layout_below="@+id/tvTitle"
                    android:layout_marginTop="5dp"
                    android:layout_toRightOf="@+id/ivPosterImage"
                    android:text="@string/critics_score"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/tvAudienceScore"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/tvCriticsScore"
                    android:layout_below="@+id/tvCriticsScore"
                    android:layout_marginTop="5dp"
                    android:text="@string/audi_score"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/tvCast"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/tvAudienceScore"
                    android:layout_below="@+id/tvAudienceScore"
                    android:layout_marginTop="5dp"
                    android:text="@string/cast"
                    android:textSize="14sp" />
            </LinearLayout>
        </LinearLayout>

        <TextView
            android:id="@+id/tvCriticsConsensus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cosensus"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/tvSynopsis"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tvCriticsConsensus"
            android:layout_marginTop="48dp"
            android:text="@string/synopsis"
            android:textSize="17sp" />
    </LinearLayout>
</ScrollView>

</RelativeLayout>



您的scrollview不包含任何内容,这就是为什么您看不到我的样子@TyczjScrollView应该放在哪里?帮我编辑代码@xavierDo你想要整个页面滚动还是只想要底部的部分(图片下方)?我想要所有页面滚动,那么它的滚动查看代码是什么呢@XavierI编辑了我的答案,并对你的布局提出了建议。希望它能解决你的问题。我有一个问题,如果我使用你的代码,像这样@+id/ivPosterImage不是同一个RelativeLayout中的兄弟姐妹,而LinearLayout中的布局参数无效,为什么?如果你想滚动它,你必须在滚动视图中播放,但是scroll view只能有一个直接的父对象,因此为了让你的代码正常工作,用相对编辑的答案替换线性布局问题重新浮出水面,成为android:layout_alignLeft=“@+id/scrollView1”,但在文本视图我清理了你的错误后,scroll view仍然无法@suhailwhat scroll view仍然无法正常工作,看起来一团糟@Suhail,cek我的编辑帖子
<RelativeLayout 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:padding="5dp"
tools:context=".BoxOfficeDetailActivity" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="10dp" >

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

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

            <ImageView
                android:id="@+id/ivPosterImage"
                android:layout_width="150dp"
                android:layout_height="200dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:adjustViewBounds="true"
                android:maxHeight="300dp"
                android:src="@drawable/large_movie_poster" />

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

                <TextView
                    android:id="@+id/tvTitle"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignTop="@+id/ivPosterImage"
                    android:layout_marginLeft="8dp"
                    android:layout_marginTop="5dp"
                    android:layout_toRightOf="@+id/ivPosterImage"
                    android:text="@string/movie_title"
                    android:textSize="18sp" />

                <TextView
                    android:id="@+id/tvCriticsScore"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/tvTitle"
                    android:layout_below="@+id/tvTitle"
                    android:layout_marginTop="5dp"
                    android:layout_toRightOf="@+id/ivPosterImage"
                    android:text="@string/critics_score"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/tvAudienceScore"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/tvCriticsScore"
                    android:layout_below="@+id/tvCriticsScore"
                    android:layout_marginTop="5dp"
                    android:text="@string/audi_score"
                    android:textSize="14sp" />

                <TextView
                    android:id="@+id/tvCast"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/tvAudienceScore"
                    android:layout_below="@+id/tvAudienceScore"
                    android:layout_marginTop="5dp"
                    android:text="@string/cast"
                    android:textSize="14sp" />
            </LinearLayout>
        </LinearLayout>

        <TextView
            android:id="@+id/tvCriticsConsensus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cosensus"
            android:textSize="17sp" />

        <TextView
            android:id="@+id/tvSynopsis"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tvCriticsConsensus"
            android:layout_marginTop="48dp"
            android:text="@string/synopsis"
            android:textSize="17sp" />
    </LinearLayout>
</ScrollView>

</RelativeLayout>
    <RelativeLayout 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:padding="5dp"
        tools:context=".BoxOfficeDetailActivity" >

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp" 
        android:id="@+id/scrollView1">

       <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
         >

        <ImageView
            android:id="@+id/ivPosterImage"
            android:layout_width="150dp"
            android:layout_height="200dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:adjustViewBounds="true"
            android:maxHeight="300dp"
            android:src="@drawable/large_movie_poster" />

        <TextView
            android:id="@+id/tvCriticsScore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/tvTitle"
            android:layout_below="@+id/tvTitle"
            android:layout_marginTop="5dp"
            android:layout_toRightOf="@+id/ivPosterImage"
            android:text="@string/critics_score"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/tvCast"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/tvAudienceScore"
            android:layout_below="@+id/tvAudienceScore"
            android:text="@string/cast"
            android:layout_marginTop="5dp"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/tvTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/ivPosterImage"
            android:layout_marginLeft="8dp"
            android:layout_toRightOf="@+id/ivPosterImage"
            android:text="@string/movie_title"
            android:layout_marginTop="5dp"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/tvAudienceScore"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/tvCriticsScore"
            android:layout_below="@+id/tvCriticsScore"
            android:layout_marginTop="5dp"
            android:text="@string/audi_score"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/tvSynopsis"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/scrollView1"
            android:layout_below="@+id/tvCriticsConsensus"
            android:layout_marginTop="48dp"
            android:textSize="17sp"
            android:text="@string/synopsis" />

        <TextView
            android:id="@+id/tvCriticsConsensus"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/cosensus"
            android:textSize="17sp" />

    </RelativeLayout>
  </ScrollView>
 </RelativeLayout>