I have built ARSimple
demo from ARToolkit for Android, but this is the result:
Is there a way to make the view fill the entire screen?
I have built ARSimple
demo from ARToolkit for Android, but this is the result:
Is there a way to make the view fill the entire screen?
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.
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.");
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>