2011-12-27 112 views
1

这是我布局XMLRelativelayoutScrollview: -Android的滚动视图缩小ImageView的

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <RelativeLayout 
     android:id="@+id/layout1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="10dp" > 

     <View 
      android:id="@+id/separator1" 
      android:layout_width="fill_parent" 
      android:layout_height="3dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/title" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/separator1" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:text="Merry Xmas" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textStyle="bold" /> 

     <View 
      android:id="@+id/separator2" 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:layout_below="@+id/title" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:background="@android:color/white" /> 

     <ImageView 
      android:id="@+id/image1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_below="@+id/separator2" 
      android:scaleType="fitCenter" /> 

     <View 
      android:id="@+id/separator3" 
      android:layout_width="fill_parent" 
      android:layout_height="1dp" 
      android:layout_below="@+id/image1" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:background="@android:color/white" /> 

     <TextView 
      android:id="@+id/text2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/separator3" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="5dp" 
      android:text="Happy New Year" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:textStyle="bold" /> 
    </RelativeLayout> 
</ScrollView> 

这里是我的问题: -

  • 如果我删除ScrollView标签中,ImagView延伸和填充了宽度,这是我想要的。
  • 如果我添加了ScrollView标签,由于某种原因它缩小了ImagView

任何想法我怎么可以将ScrollView,并有ImageView填补了宽?

回答

0

您是否尝试过设置RealtiveLayout来填充父项?另外我注意到有时候一个RelativeLayout会缩小imageViews。也许你可以尝试使用LinearLayout。

+0

尝试了您所建议的所有相同结果。 – Maurice 2011-12-27 09:05:01

+0

如果您只将ImageView添加到ScrollView中,它会缩小它吗?如果是,那么ScrollView可能有默认的填充,你可以设置为零。此外,使用ImageView android:scaleType =“fitCenter”,您可以尝试不同的设置。我没有自己的图片来实验自己... – Lumis 2011-12-27 09:13:50

+0

是的,它缩小了图像,如果只是scrollview中的imageview。我摆脱了android:scaleType,试图为scrollview和imageview设置android:padding =“0dp”,仍然是nada。 – Maurice 2011-12-27 09:18:01