我试图整理一个Android应用程序,它将以某种方式拍照并处理它.我希望布局与Google Goggles类似.含义,顶部的相机预览,以及使用纵向方向的底部的一些控件.
我已经使用此处的代码示例构建了第一个版本.这有效,但我想在底部添加一个按钮.
我修改了我的main.xml,看起来如下(基于这篇文章的评论):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.view.SurfaceView android:id="@+id/preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true" />
<Button android:id="@+id/snap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Snap"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但是当我运行此代码时,我得到以下异常:
E/AndroidRuntime( 199): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 199): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.beerometer/com.beerometer.ImageCapture}: android.view.InflateException: Binary XML file line #6: Error inflating class Android.view.SurfaceView
E/AndroidRuntime( 199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
E/AndroidRuntime( 199): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 199): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime( 199): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 199): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 199): …Run Code Online (Sandbox Code Playgroud)