2014-05-15 32 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()属性

相关问题