ScrollView不会在布局中滚动?

时间:2015-08-16 21:51:04

标签: android android-layout

我有这个顺序RelativeLayout / ScrollView / Relative Layout / Relative Layout,在最后的相对布局里面我有两个线性布局。

不知道为什么会这样。我对其他活动的布局几乎相同,并且它正在工作。

这是xml代码:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" 
    >
    <ScrollView 
        android:layout_width="match_parent"
        android:layout_height="4000dp"
        android:paddingBottom="5dp"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingTop="5dp"
        android:orientation="vertical"  
        android:scrollbars="none"  
        android:background="@drawable/url" >

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

            <!-- Thumbnail Image -->

            <com.dusandimitrijevic.modification.TouchImageView
                android:id="@+id/thumbnail"
                android:layout_width="115dp"
                android:layout_height="180dp"
                android:layout_alignParentLeft="true"
                android:layout_marginRight="8dp"
                android:src="@drawable/ic_horor_filmovi_ikonica" />

            <!-- Naslov Filma -->
            <TextView
                android:id="@+id/naslov"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_toRightOf="@id/thumbnail"
                android:text="Naslov"
                android:textAppearance="?android:attr/textAppearanceLarge" >

            </TextView>
            <!-- Godina izdanja Filma -->

            <TextView
                android:id="@+id/releaseYear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/naslov"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/naslov"
                android:layout_marginTop="3dp"
                android:text="TextView"
                android:textColor="@color/black" />

            <ImageView
                android:id="@+id/rating_star"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/thumbnail"
                android:layout_marginBottom="42dp"
                android:layout_toRightOf="@+id/thumbnail"
                android:src="@drawable/ic_actions_rating_icon" />

            <Button
                android:id="@+id/url_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/thumbnail"
                android:layout_alignRight="@+id/scrollView"
                android:layout_toRightOf="@+id/thumbnail"
                android:background="@color/transparent_grey"
                android:text="Pogledaj insert iz filma" />

            <TextView
                android:id="@+id/rating"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/rating_star"
                android:layout_alignTop="@+id/rating_star"
                android:layout_toRightOf="@+id/rating_star"
                android:gravity="center"
                android:text="TextView"
                android:textColor="@color/black"
                android:textSize="@dimen/rating" />

            <!-- Opis Filma -->
            <RelativeLayout
                android:id="@+id/relativeLayout1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/thumbnail"
                android:layout_marginTop="14dp"
                android:background="@drawable/layout_round_rect_shape" >

                <TextView
                    android:id="@+id/description"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:layout_marginLeft="18dp"
                    android:layout_marginTop="16dp"
                    android:scrollbars="vertical"
                    android:text="TextView"
                    android:textColor="#7F0000"
                    android:textSize="18sp" />
            </RelativeLayout>
            <!-- Opis Filma Zavrsetak -->


            <!-- Glumci -->
            <RelativeLayout
                android:id="@+id/relativeLayout2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/relativeLayout1"
                android:layout_marginTop="12dp"
                android:background="@drawable/layout_round_rect_shape"
                android:orientation="vertical" >

                <LinearLayout
                    android:id="@+id/linearLayoutActors"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal" >

                    <com.android.volley.toolbox.NetworkImageView
                        android:id="@+id/Image1"
                        android:layout_width="40dp"
                        android:layout_height="140dp"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginTop="16dp"
                        android:layout_weight="1"
                        android:scaleType="fitCenter"
                        android:src="@drawable/ic_horor_filmovi_ikonica" />

                    <com.android.volley.toolbox.NetworkImageView
                        android:id="@+id/Image2"
                        android:layout_width="40dp"
                        android:layout_height="140dp"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginTop="16dp"
                        android:layout_weight="1"
                        android:scaleType="fitCenter"
                        android:src="@drawable/ic_horor_filmovi_ikonica" />

                    <com.android.volley.toolbox.NetworkImageView
                        android:id="@+id/Image3"
                        android:layout_width="40dp"
                        android:layout_height="140dp"
                        android:layout_gravity="center_horizontal"
                        android:layout_marginTop="16dp"
                        android:layout_weight="1"
                        android:scaleType="fitCenter"
                        android:src="@drawable/ic_horor_filmovi_ikonica" />
                </LinearLayout>

                <LinearLayout
                    android:id="@+id/linearLayoutTextView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/linearLayoutActors"
                    android:orientation="horizontal" >

                    <TextView
                        android:id="@+id/ime1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="Ime"
                        android:textColor="#7F0000"
                        android:textSize="20sp" />

                    <TextView
                        android:id="@+id/ime2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="Ime"
                        android:textColor="#7F0000"
                        android:textSize="20sp" />

                    <TextView
                        android:id="@+id/ime3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="center"
                        android:text="Ime"
                        android:textColor="#7F0000"
                        android:textSize="20sp" />
                </LinearLayout>
            </RelativeLayout>
            <!-- Glumci -->

            <!-- Slike -->
            <RelativeLayout
                android:id="@+id/relativeLayout3"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_marginTop="12dp"
                android:orientation= "vertical"
                android:layout_below="@+id/relativeLayout2"
                 >

                    <LinearLayout
                        android:background="@drawable/layout_round_rect_shape"
                        android:id="@+id/linearLayoutImages"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal" >

                            <android.support.v4.view.ViewPager
                                android:id="@+id/pager"
                                android:layout_width="match_parent"
                                android:layout_height="186dp"
                                android:fadingEdge="vertical" />

                            <com.dusandimitrijevic.modification.TouchImageView
                                android:id="@+id/image1"
                                android:layout_width="115dp"
                                android:layout_height="150dp"
                                android:src="@drawable/ic_horor_filmovi_ikonica" >
                            </com.dusandimitrijevic.modification.TouchImageView>    

                            <com.dusandimitrijevic.modification.TouchImageView
                                android:id="@+id/image2"
                                android:layout_width="115dp"
                                android:layout_height="150dp"
                                android:src="@drawable/ic_horor_filmovi_ikonica" >
                            </com.dusandimitrijevic.modification.TouchImageView>

                            <com.dusandimitrijevic.modification.TouchImageView
                                android:id="@+id/image3"
                                android:layout_width="115dp"
                                android:layout_height="150dp"
                                android:src="@drawable/ic_horor_filmovi_ikonica" >
                           </com.dusandimitrijevic.modification.TouchImageView>     

                            <com.dusandimitrijevic.modification.TouchImageView
                                android:id="@+id/image4"
                                android:layout_width="115dp"
                                android:layout_height="150dp"
                                android:src="@drawable/ic_horor_filmovi_ikonica" >
                            </com.dusandimitrijevic.modification.TouchImageView>                            


                    </LinearLayout>

            </RelativeLayout>
            <!-- Slike -->

        </RelativeLayout>

    </ScrollView>      

</RelativeLayout>       

更新

具有ScrollView并且正在运行的布局:

    <?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" 
    >

    <ScrollView                 
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="@drawable/url"     
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"  
        android:scrollbars="none"    
         >

        <RelativeLayout            
            android:id="@+id/relativeLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"            
            >   

            <com.android.volley.toolbox.NetworkImageView
                android:id="@+id/slika"
                android:layout_width="match_parent"
                android:layout_height="380dp"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:src="@drawable/ic_horor_filmovi_ikonica" />

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/slika"
                android:layout_alignRight="@+id/slika"
                android:layout_below="@+id/slika"
                android:layout_marginTop="14dp"
                android:text="Orginalni naslov:"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/naslov"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/textView1"
                android:layout_alignRight="@+id/textView1"
                android:layout_below="@+id/textView1"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView 
                android:id="@+id/datum_prikazivanja_filma"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/naslov"
                android:layout_alignRight="@+id/naslov"
                android:layout_marginTop="10dp"
                android:layout_below="@+id/naslov"
                android:textAppearance="?android:attr/textAppearanceLarge"
                />

            <TextView 
                android:id="@+id/textView3"
                android:layout_marginTop="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/datum_prikazivanja_filma"
                android:layout_alignRight="@+id/datum_prikazivanja_filma"
                android:layout_below="@+id/datum_prikazivanja_filma"
                android:layout_marginBottom="5dp"
                android:text="Glumci:"
                android:textAppearance="?android:attr/textAppearanceLarge"
                />

            <View
                 android:id="@+id/view"
                 android:layout_alignLeft="@+id/textView3"
                 android:layout_alignRight="@+id/textView3"
                 android:layout_width="fill_parent"
                 android:layout_height="3dp"
                 android:background="#c0c0c0"
                 android:layout_below="@+id/textView3"/>

            <LinearLayout
                android:id="@+id/linearLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/view"
                android:layout_marginBottom="12dp"
                android:layout_marginTop="6dp"
                android:orientation="horizontal" >

                <com.android.volley.toolbox.NetworkImageView
                    android:id="@+id/Image1"
                    android:layout_width="60dp"
                    android:layout_height="60dp"                    
                    android:layout_marginTop="16dp"
                    android:layout_weight="1"
                    android:layout_gravity="center_horizontal"
                    android:scaleType="fitCenter"
                    android:src="@drawable/ic_horor_filmovi_ikonica" />

                <com.android.volley.toolbox.NetworkImageView
                    android:id="@+id/Image2"
                    android:src="@drawable/ic_horor_filmovi_ikonica"
                    android:layout_marginTop="16dp"
                    android:layout_weight="1"   
                    android:layout_gravity="center_horizontal"            
                    android:scaleType="fitCenter"
                    android:layout_width="60dp"
                    android:layout_height="60dp"/>

                <com.android.volley.toolbox.NetworkImageView
                    android:id="@+id/Image3"
                    android:src="@drawable/ic_horor_filmovi_ikonica"
                    android:layout_marginTop="16dp"
                    android:layout_weight="1"        
                    android:layout_gravity="center_horizontal"       
                    android:scaleType="fitCenter"
                    android:layout_width="60dp"
                    android:layout_height="60dp"/>

            </LinearLayout>

            <LinearLayout
                android:id="@+id/linearLayoutTextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/linearLayout"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/ime1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="20sp"
                    android:textColor="@color/black"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="Ime" />

                <TextView
                    android:id="@+id/ime2"
                    android:textSize="20sp"
                    android:textColor="@color/black"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="Ime" />

                <TextView
                    android:id="@+id/ime3"
                    android:textSize="20sp"
                    android:textColor="@color/black"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:gravity="center"
                    android:text="Ime" />
            </LinearLayout>

            <View
                 android:id="@+id/view2"
                 android:layout_width="fill_parent"
                 android:layout_height="3dp"
                 android:background="#c0c0c0"
                 android:layout_below="@+id/linearLayoutTextView"/>

            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/view2"
                android:layout_alignRight="@+id/view2"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/view2"
                android:layout_marginTop="18dp"
                android:text="Opis filma:"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView 
                android:id="@+id/opisFilma"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentRight="true"
                android:layout_alignLeft="@+id/textView4"
                android:layout_alignRight="@+id/textView4"
                android:gravity="center_vertical"
                android:layout_below="@+id/textView4"
                android:layout_marginTop="5dp"
                android:text="TextView"             
                android:textColor="@color/black"
                android:textSize="20sp"/>           

        </RelativeLayout>   

    </ScrollView>

    <Button
        android:id="@+id/watch_trailer"
        android:background="@drawable/dugme_trailer_selector"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:textColor="@color/white"
        android:text="Pogledaj trailer" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

我认为你的问题在这里 android:layout_height =“4000dp”。对于scrollView,您的内容不需要滚动,因为它不需要超过4000dp

尝试将其更改为match_parent

更新2

更改此

    <ScrollView                  
        xmlns:android="http://schemas.android.com/apk/res/android"  
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:orientation="vertical"  
        android:scrollbars="none">

        <RelativeLayout            
            android:id="@+id/relativeLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            android:background="@drawable/url">