0

I want to display an image to be fullscreen :

public class PhotoPleinEcranActivity extends Activity {

    private Bundle data;
    private ImageView img;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.photo_plein_ecran);

        img = (ImageView)findViewById(R.id.zoom);

        BitmapFactory.Options bfOptions = new BitmapFactory.Options();
        bfOptions.inDither = true;                     //Disable Dithering mode
        bfOptions.inPurgeable = true;                   //Tell to gc that whether it needs free memory, the Bitmap can be cleared
        bfOptions.inInputShareable = true;              //Which kind of reference will be used to recover the Bitmap data after being clear, when it will be used in the future
        bfOptions.inTempStorage = new byte[32 * 1024];

        data = getIntent().getExtras();

        FileInputStream fs = null;
        Bitmap bm;
        try {
            fs = new FileInputStream(new File(data.getString("path")));
            if(fs != null) {
                bm = BitmapFactory.decodeFileDescriptor(fs.getFD(), null, bfOptions);
                img.setImageBitmap(bm);
            }
        } catch (IOException e) {
        } finally {
            if(fs != null) {
                try {
                    fs.close();
                } catch (IOException e) {
                }
            }
        }

    }

}

The layout :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="0dip"
    android:layout_marginBottom="0dip"
    android:paddingTop="0dip"
    android:paddingBottom="0dip"
    android:orientation="horizontal">

    <ImageView
        android:id="@+id/zoom"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="0dip"
        android:layout_marginBottom="0dip"
        android:paddingTop="0dip"
        android:paddingBottom="0dip"
    />

</LinearLayout>

Manifest file :

<activity
     android:name="com.ambre.impots.PhotoPleinEcranActivity"
     android:label="@string/galleryPhotos"
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>

At runtime there is a grey field at the bottom of the image ( I surrounded the grey field by a yellow color ) :

enter image description here

So how to make that grey field disappear ?

pheromix
  • 18,213
  • 29
  • 88
  • 158
  • try adding `android:scaleType = "centerCrop"` to your `imageView` – hrskrs May 05 '15 at 09:09
  • try `android:scaleType="fitXY"` and `android:adjustViewBounds="true"` – M D May 05 '15 at 09:09
  • possible duplicate of [How to show imageView full screen on imageView click?](http://stackoverflow.com/questions/24463691/how-to-show-imageview-full-screen-on-imageview-click) – Haresh Chhelana May 05 '15 at 09:20

4 Answers4

3

This will solve your problem.

Add below line in ImageView.

android:scaleType="fitXY"
Pavi
  • 46
  • 2
2

add android:scaleType="fitXY" to your ImageView, fitXY, will fill width and height independently to match the destination

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
2

add property scaleType to fitXY like this

<ImageView
        android:id="@+id/zoom"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="0dip"
        android:layout_marginBottom="0dip"
        android:paddingTop="0dip"
        android:paddingBottom="0dip"
        android:scaleType="fitXY" />
Sajal
  • 1,452
  • 2
  • 14
  • 17
2

Change your image view like this

 <ImageView
    android:id="@+id/zoom"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="0dip"
    android:layout_marginTop="0dip"
    android:adjustViewBounds="true"
    android:paddingBottom="0dip"
    android:paddingTop="0dip"
    android:scaleType="fitXY" />
Assad
  • 291
  • 1
  • 4
  • 16