2011-07-15 23 views
0

2つの画像ビューを持つHorizo​​ntalScrollViewがあります。 Horizo​​ntalScrollViewはScrollViewに組み込まれています。 画像が大きすぎて(幅や高さ)フィットしないと、画面サイズではなくScrollViewのサイズに切り取られます。 小さい場合は変更しません。画像ビューをスクロールビューサイズに合わせる

私のxml:

<ScrollView android:id="@+id/scrollView" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:layout_below="@id/headerappview" 
    android:layout_above="@id/bottomBar" 
    android:background="@color/white"> 

    <HorizontalScrollView android:layout_height="wrap_content" 
     android:layout_below="@+id/txtAdditionalContent" 
     android:id="@+id/hscrollview" 
     android:paddingBottom="22px" 
     android:layout_gravity="center_horizontal" 
     android:layout_width="wrap_content"> 

     <LinearLayout android:layout_height="wrap_content" 
      android:gravity="center_vertical" android:layout_width="wrap_content"> 

      <ImageView android:id="@+id/img2" android:src="@drawable/icon" 
       android:paddingRight="25px" 
       android:scaleType="fitXY" 
       android:adjustViewBounds="true" 
       android:cropToPadding="true" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content"></ImageView> 

      <ImageView android:id="@+id/img3" android:src="@drawable/icon" 
       android:cropToPadding="true" 
       android:scaleType="fitXY" 
       android:adjustViewBounds="true" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 
      </ImageView> 
     </LinearLayout> 

    </HorizontalScrollView> 

</ScrollView> 

(私の下手な英語のため申し訳ありませんが)

答えて

1

あなたは私たちがあなたがイメージを切り取るか、画像を拡大縮小するかどうかを教えてくださいことはできますか?

あなたはImageViewの程度

android:cropToPadding="false" 

詳細はhere

+0

はい写真を拡大縮小します。しかし、私の画像は、このパラメータの有無にかかわらず同じサイズを保持します – g123k

1

で、ちょうど大きな画像を拡大縮小し、それが設定され、その後合うようにしたい場合は

<ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"  
     android:fillViewport="true" 
     android:fadingEdge="none" 
     android:background="@drawable/bg_app" > 
をscrollviewするfadingEdgeとfillViewportを追加してHorizo​​ntalScrollView

してください
関連する問題