Reputation: 799
I have created a gallery which has default images when , one of it is clicked and displayed in other activity, but my problem is it does not occupy the whole screen when the image is loaded.
Here's the 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>
and the images is loaded to this imageview from activity, using the following code.
Intent intent = getIntent();
int ImageId = intent.getIntExtra("drawableId", 0);
imgView = (ImageView) findViewById(R.id.imageViewEdit);
imgView.setImageResource(ImageId);
Is their a way where image occupies the whole image view. Experts please help me, am new to android. Thanks in advance.
Upvotes: 0
Views: 544
Reputation: 99
Refer this link https://developer.android.com/reference/android/widget/ImageView.ScaleType.html
Add android:scaleType="FIT_XY"
to your ImageView.
Upvotes: 0
Reputation: 12919
Change the ScaleType
of the ImageView
. Add this to your ImageView
tag:
android:scaleType = "fitCenter"
Upvotes: 0
Reputation: 2732
set the android:scaleType
attribute on the ImageView, something like centerCrop should fill the screen
Upvotes: 0
Reputation: 13520
Change
imgView.setImageResource(ImageId);
to
imgView.setBackgroundResource(ImageId);
Upvotes: 1