Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a Image on FullScreen mode Android

I already know how to get my Activity as fullscreen on Android, now I need to draw a Image in this screen.

This is my XML layout.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/image01" android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</LinearLayout>

This image is dynamic generated and drawed in the ImageView.

This is my code on my Activity.

public void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);
}

But when running, the Activity is FullScreen, but the ImageView is adjusted in the center.

What's wrong?

I added the following code to see the components dimensions.

    View view = getWindow().getDecorView();
    Log.i("RMSDK:J:IbaReader(decor)",
            "[w=" + view.getWidth() + ":h=" + view.getHeight() + "]");
    Log.i("RMSDK:J:IbaReader(img)",
            "[w=" + img.getWidth() + ":h=" + img.getHeight() + "]");

This results in [w=320:h=480] in both cases.

This is my draw method.

private void draw() {
    byte[] image = services.getImageBuffer(600, 1024);
    Bitmap bmp = Bitmap.createBitmap(600, 1024, Bitmap.Config.RGB_565);
    int row = 0, col = 0;
    for (int i = 0; i < image.length; i += 3) {
        bmp.setPixel(col++, row, image[i + 2] & image[i + 1] & image[i]);
        if (col == 600) {
            col = 0;
            row++;
        }
    }
    img.setImageBitmap(bmp);
}
like image 700
Marcos Vasconcelos Avatar asked Jan 14 '11 18:01

Marcos Vasconcelos


1 Answers

Add android:scaleType="fitXY" to you imageview

like image 109
Labeeb Panampullan Avatar answered Oct 26 '22 11:10

Labeeb Panampullan