Aakash
Aakash

Reputation: 65

How to set imageview fit to sreen?

I have use the android studio and set the image view fit to screen using relative background image i give layout top margin and i set image view fit to screen below part

android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"

android:background="@drawable/backgroud">

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="500dp"
    android:background="@drawable/blacksquare"
    android:alpha=".33"
    />

Upvotes: 4

Views: 16256

Answers (2)

MFP
MFP

Reputation: 1141

Use following code for set image in full screen.

<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/blacksquare"
android:alpha=".33"
android:layout_marginTop="10dp"
ScaleType="fitXY"
/>

Upvotes: 0

Pravinsingh Waghela
Pravinsingh Waghela

Reputation: 2534

Write the Following ImageView Tag in your Parent Layout.

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="fitXY"
    android:background="@drawable/blacksquare"
    />

and you can also remove the Paddings from your parent Layout Tag to get fit the Image View in screen without padding..

Upvotes: 7

Related Questions