在Android上获取ARToolkit演示以填满整个屏幕

时间:2015-05-31 00:43:45

标签: artoolkit

我已经从ARToolkit for Android构建了ARSimple演示,但结果如下:

The view does not fill the screen

有没有办法让视图填满整个屏幕?

3 个答案:

答案 0 :(得分:1)

我通过将main.xml文件中的单位从px更改为dp来解决了这个问题。

i.e.from:

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

要:

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

设置为match_parents没有帮助,相机视图填满整个屏幕,但屏幕看起来不成比例。

答案 1 :(得分:0)

修改onResume()中的ARActivity.java方法,无需拉伸图像即可完成。

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

答案 2 :(得分:0)

修改main.xml文件并将FrameLayout宽度和高度属性更改为“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>