2011-05-30 25 views
0

在我的應用程序中,我使用ScrollView來顯示圖像。 有時候,當圖像比視圖更大時,我想顯示圖像的中心,然後將圖像滾動到邊緣。 ScrollView包含一個ImageView容器。 如何做? 謝謝, Eyal。android ScrollView指向視圖的中心

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <RelativeLayout android:id="@+id/relativeLayout1" 
     android:layout_height="match_parent" 
     android:layout_width="match_parent"> 

     <ScrollView android:id="@+id/scrollView1" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_weight="1.0"> 

      <ImageView android:id="@+id/imgImageView" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_width="wrap_content" 
       android:layout_gravity="center"/> 

     </ScrollView> 

     <TextView android:layout_height="wrap_content" 
      android:id="@+id/addrTextView" 
      android:layout_alignParentBottom="true" 
      android:layout_width="match_parent" 
      android:gravity="center" 
      android:textSize="12px" 
      android:layout_weight="0.0"/> 
    </RelativeLayout> 

</LinearLayout> 

回答

0

在ImageView的把

android:layout_centerInParent="true"