scrollview在布局活动的底部留下额外的空间

时间:2016-08-31 08:10:15

标签: android android-layout android-scrollview

我的// This snippet shows the system bars. It does this by removing all the flags // except for the ones that make the content appear under the system bars. private void showSystemUI() { mDecorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); } 会留下一些Scrollview以下的空间我是android的新手,请帮助我的代码:

layouts

4 个答案:

答案 0 :(得分:2)

在ScrollView中添加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)

我遇到了同样的问题,并在android:layout_gravity="top"内的LinearLayout上添加了ScrollView

答案 2 :(得分:0)

就我而言,我发现背景高度在底部占用了更多空间。 解决方案:我已经将背景从相对布局移到了滚动视图,并且已经解决了这个问题。

e.Row.Attributes["onclick"] = HttpUtility.HtmlDecode(
string.Format("$(#detailDataRow{0}).addClass('overlayVisible');$(#detailDataRow{0}).removeClass('overlayHidden')", e.Row.RowIndex));

希望这可以解决您的问题

答案 3 :(得分:0)

在“滚动视图”中,使用android:fillViewport属性设置滚动视图的高度和宽度填充端口(与父代匹配)。如果我们不在滚动视图中使用此属性,则其表现为wrap_content

代码:

 <ScrollView     
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/scrollviewdb"     
android:layout_width="match_parent"    
android:layout_height="wrap_content"
 android:fillViewport="true" >  
<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>