0

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

视图没有填满屏幕

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

4

3 回答 3

1

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

即来自:

<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 没有帮助,相机视图填满了整个屏幕,但屏幕看起来不成比例。

于 2015-10-15T08:07:03.167 回答
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.");

在此处输入图像描述

于 2015-06-01T13:10:36.637 回答
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>
于 2015-07-23T18:20:56.683 回答