2013-03-11 44 views
0

我试图创建一个由一个长图像组成的布局,它应该只能垂直滚动。使用ScrollView滚动ImageView

即 - 它应该拉伸到整个屏幕宽度并且拉伸到整个高度。

我的布局是这样做的,但它会在图像前后产生奇怪的间隙。每个间隙大约需要2/3的屏幕,并且可以向下滚动。

如何删除间隙以便只有屏幕上出现ImageView

我的活动XML是这样的:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_marginTop="0dp" > 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="0dp" 
     tools:context=".HelpActivity" > 

     <ImageView 
      android:id="@+id/imageHelp" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="0dp" 
      android:src="@drawable/tutorial_with_text" /> 
    </LinearLayout> 

</ScrollView> 
+0

尝试增加图像的背景Imageview – 2013-03-11 10:58:17

+0

而你并不需要LinearLayout。而且你不需要xmlns:android在布局中两次。 – 2013-03-11 10:59:03

+0

谢谢。你是对的 :) – Roman 2013-03-11 11:04:46

回答

6

找到了解决办法:以供将来参考:

使用Android:adjustViewBounds上的ImageView = “真”