2015-03-25 51 views
2

这是我的scrollView的布局。它只是无限滚动。我需要为用户在活动中看到的元素提供滚动。然而,我尝试了所有的努力,但没有成功。继承人的布局..如何避免此Android Scrollview进入无限滚动?

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" > 

<LinearLayout 
    android:id="@+id/parentLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:layout_marginLeft="-20dp" 
    android:layout_marginStart="-20dp" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </Button> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </Button> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" > 
     </Button> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </Button> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 
     </Button> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="15dp" 
     android:layout_marginLeft="100dp" 
     android:layout_marginStart="100dp" 
     android:gravity="center" 
     android:text="Create event" > 
    </Button> 
</LinearLayout> 

+0

你为什么用这个? android:layout_marginLeft =“ - 20dp” android:layout_marginStart =“ - 20dp” – 2015-03-25 07:36:28

+0

编辑我的问题。对不起。它应该是出现在线性布局中的按钮。 – Nevermore 2015-03-25 07:47:12

+0

不错。现在运行你的应用程序,并让我知道 – 2015-03-25 07:49:49

回答

2

设置的LinearLayout(ID parentLayout)的高度WRAP_CONTENT。

ScrollView设置为wrap_content,但其子设置为fill_parent。这是没有道理的,因为某些东西需要提供大小。

+0

它帮助。谢谢。 – Nevermore 2015-03-25 08:05:41