0

This is the code:

public class MyView extends ImageView
{

    Canvas canvas = new Canvas();
    Context context2;

    private Bitmap zamek;



    public MyView(Context context)
    {
        super(context);

        context2=context;


    zamek = BitmapFactory.decodeResource(getResources(), R.drawable.gorna_czesc_pistoletu);
     //zamek = Bitmap.createScaledBitmap(zamek,1080, 1701, true);   
    }
    @Override
    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);


                canvas.drawBitmap(zamek, 0, 0, null);

                invalidate();


    }

}

And xml:

<FrameLayout
    android:id="@+id/layout_all"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/imageView_body"            
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.aaa.bbb.MyView
       android:id="@+id/myView"
       android:layout_width="match_parent"
       android:layout_height="match_parent" />

</FrameLayout>

I want to fit the bitmap to the View, without changing its resolution. My bitmap has a size of 1200x800 and this size occupies a part of the smartphone screen.

I want to get effect as in a standard ImageView, where you only need to add a parameter fill_parent.

To better explain it:

I want the bitmap was exactly the size as the image in ImageView(imageView_body in my xml). Both have a resolution of 1200x800.

pawel22
  • 23
  • 5
  • possible duplicate of [Fit image into ImageView, keep aspect ratio and then resize ImageView to image dimensions?](http://stackoverflow.com/questions/8232608/fit-image-into-imageview-keep-aspect-ratio-and-then-resize-imageview-to-image-d) – jlopez Jun 17 '15 at 08:40
  • No, my problem is completely different – pawel22 Jun 17 '15 at 08:50

0 Answers0