2013-05-21 19 views

cevap

3

Ben (yaklaşım this question yılında birine benzer) Aşağıdaki şekilde yapmaya öneririm.

E.g. Sen (Onların cevapsız böylece başlık ve sekmeler ne olduğundan emin değilim) Aşağıdaki xml:

<ScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:id="@+id/scroller"> 
     <ImageView 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_gravity="center" 
      android:id="@+id/image" 
      android:src="@drawable/image001" 
      android:scaleType="fitXY" /> 
</ScrollView> 

Sonra aktivite şöyle görünebilir:

küçük resmin durumunda
public class MyActivity extends Activity { 

    private static final String TAG = "MyActivity"; 

    private ScrollView mScroll = null; 
    private ImageView mImage = null; 

    private ViewTreeObserver.OnGlobalLayoutListener mLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() { 
     @Override 
     public void onGlobalLayout() { 
      final Rect imageRect = new Rect(0, 0, mImage.getWidth(), mImage.getHeight()); 
      final Rect imageVisibleRect = new Rect(imageRect); 

      mScroll.getChildVisibleRect(mImage, imageVisibleRect, null); 

      if (imageVisibleRect.height() < imageRect.height() || 
        imageVisibleRect.width() < imageRect.width()) { 
       Log.w(TAG, "image is not fully visible"); 
      } else { 
       Log.w(TAG, "image is fully visible"); 
      } 

      mScroll.getViewTreeObserver().removeOnGlobalLayoutListener(mLayoutListener); 
     } 
    }; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     // Show the layout with the test view 
     setContentView(R.layout.main); 

     mScroll = (ScrollView) findViewById(R.id.scroller); 
     mImage = (ImageView) findViewById(R.id.image); 

     mScroll.getViewTreeObserver().addOnGlobalLayoutListener(mLayoutListener); 
    } 
} 

o kaydeder: görüntü tamamen görünür.

Ancak, Sen (benim anlayış uyarınca) aşağıdaki tutarsızlık hakkında bilmelidir: Sen büyük bir imaja sahip, ancak (eğer android:layout_width="wrap_content" set örneğin) o ölçekli bak ne zaman kendisine ölçekleme yapıyorum ama eğer gerçek ImageView yüksekliği olacak görüntünün tam yüksekliği olarak (ve ScrollView bile kaydırma yapacak), bu nedenle adjustViewBounds gerekli olabilir. Bunun nedeninin nedeni, FrameLayoutdoesn't care about layout_width and layout_height of childs.

İlgili konular