滚动视图留下多余的空间布局,在活动的底部

问题描述:

Scrollview留出空间在某些layouts我是新至Android请帮帮这里是我的代码:滚动视图留下多余的空间布局,在活动的底部

<ScrollView  
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollviewdb"  
    android:layout_width="match_parent"  
    android:layout_height="wrap_content" > 
    <LinearLayout  
     xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical"  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content">  
     <TextView   
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"   
      android:textSize="15sp" 
      android:padding="5dp"  
      android:id="@+id/ghavaed_text"/> 
     </LinearLayout> 
    </ScrollView> 
+1

add screenshot..so people can help you .. –

+1

欢迎来到Stack Overflow!请参考[游览](http://*.com/tour),环顾四周,阅读[帮助中心](http://*.com/help),特别是[我该如何问一个好问题?](http://*.com/help/how-to-ask) – Squazz

+0

在滚动视图中使用android:fillViewport =“true” –

添加android:fillViewport在滚动型。

<ScrollView  
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/scrollviewdb"  
    android:fillViewport="true" 
    android:layout_width="match_parent"  
    android:layout_height="wrap_content" > 
    <LinearLayout  
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical"  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content">  
     <TextView   
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"   
      android:textSize="15sp" 
      android:padding="5dp"  
      android:id="@+id/ghavaed_text"/> 
    </LinearLayout> 
</ScrollView> 

正如@Ironman解释的那样,如果ScrollView的内容总是和自身一样高,那么它将变得毫无用处。要解决此问题,您需要使用名为android:fillViewport的ScrollView属性。如果设置为true,则此属性会导致滚动视图的子级扩展到ScrollView的高度(如果需要)。当孩子比ScrollView高时,属性没有效果

+1

我给+1给你,因为你的答案是正确的,但你必须添加解释说,如果ScrollView的内容总是和自身一样高,那么它将变得毫无用处。要解决此问题,您需要使用名为android:fillViewport的ScrollView属性。如果设置为true,则此属性会导致滚动视图的子级扩展到ScrollView的高度(如果需要)。当孩子比ScrollView高,属性没有效果' – Ironman

+0

fillViewport没有工作我试过@Ironman –

+0

它不能解决fillViewport :(@MahfuzIslamBhuiyan –