2014-05-15 40 views
0

我創建了一個具有默認圖像的圖庫,當其中一個點擊並顯示在其他活動中時,但是我的問題是圖像加載時不佔用整個屏幕。不佔用整個ImageView中的圖像

這裏是XML的

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drag_activity_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".DragActivity" > 

    <ImageView 
     android:id="@+id/imageViewEdit" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/i1" /> 

</RelativeLayout> 

和圖像加載到從活動這個ImageView的,使用下面的代碼。

Intent intent = getIntent(); 
     int ImageId = intent.getIntExtra("drawableId", 0); 

     imgView = (ImageView) findViewById(R.id.imageViewEdit); 
     imgView.setImageResource(ImageId); 

enter image description here

是他們其中的圖像佔據整個圖像視圖的方法。 專家請幫助我,是新來的android。提前致謝。

回答

1

變化

imgView.setImageResource(ImageId); 

imgView.setBackgroundResource(ImageId); 
0

上設置的ImageView的android:scaleType屬性,像centerCrop應填寫屏幕

0

更改ImageViewScaleType。添加到您的ImageView標籤:

android:scaleType = "fitCenter" 
0

使用imageView.setBackground()屬性

相關問題