0

I have built ARSimple demo from ARToolkit for Android, but this is the result:

The view does not fill the screen

Is there a way to make the view fill the entire screen?

Alicia
  • 1,132
  • 1
  • 14
  • 28
  • Setting fixed size in `LayoutParams` for `glView` and `preview` in `ARActivity:onResume` seems to work, e.g. `mainLayout.addView(preview, new LayoutParams(1440,1080));`, yet I don't know why the default (`fill_parent`) does not fill the screen. – Alicia May 31 '15 at 01:16

3 Answers3

1

I resolved this problem by changing the units in the main.xml file from px to dp.

i.e.from:

<FrameLayout
android:id="@+id/mainLayout" 
android:orientation="vertical"
android:layout_width="640px"
android:layout_height="480px"
>
</FrameLayout>

To:

<FrameLayout
android:id="@+id/mainLayout" 
android:orientation="vertical"
android:layout_width="640dp"
android:layout_height="480dp"
>
</FrameLayout>    

Setting to match_parents doesn't help, the camera view fills the entire screen but the screen looks disproportionate.

gkl
  • 81
  • 4
0

Modifying the method onResume() in ARActivity.java did the trick without stretching the image.

Log.i(TAG, "GLSurfaceView created");

Point windowSize = new Point();
getWindowManager().getDefaultDisplay().getSize(windowSize);

// Assumes landscape orientation
float aspectRatio = 4.0f / 3.f;
int height = windowSize.y;
int width = Math.round(height * aspectRatio);

if (width > windowSize.x) {
    // For portrait screens instead...
    width = windowSize.x;
    height = Math.round(width * aspectRatio);
}

// Add the views to the interface
mainLayout.addView(preview, new LayoutParams(width, height));
mainLayout.addView(glView, new LayoutParams(width, height));

Log.i(TAG, "Views added to main layout.");

enter image description here

Alicia
  • 1,132
  • 1
  • 14
  • 28
0

Modify your main.xml file and change the FrameLayout width and height attributes to "match_parent"

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/topLayout" 
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >


<FrameLayout
    android:id="@+id/mainLayout" 
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   >


</FrameLayout >

</LinearLayout>
keith milton
  • 68
  • 10