【发布时间】:2010-08-01 00:43:25
【问题描述】:
这是我在 android 中的图像捕获程序的布局
<?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">
<SurfaceView android:id="@+id/surface_camera"
android:layout_width="fill_parent" android:layout_height="420px">
</SurfaceView>
<RelativeLayout android:layout_width="fill_parent"
android:layout_alignParentBottom="true" android:id="@+id/beforeClick"
android:layout_height="wrap_content" android:background="@color/clickPanelBK"
android:paddingTop="6dp" android:paddingBottom="6dp">
<Button android:gravity="center" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/capture_image_goback_btn"
android:background="@drawable/generalbutton" android:text="@string/back" />
<Button android:gravity="center"
android:layout_centerHorizontal="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/capture_image_btn"
android:background="@drawable/clickbutton" />
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent"
android:layout_alignParentBottom="true" android:id="@+id/afterClick"
android:layout_height="wrap_content" android:background="@color/clickPanelBK"
android:paddingTop="6dp" android:paddingBottom="6dp">
<Button android:gravity="center" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/img_retake"
android:background="@drawable/generalbutton" android:text="@string/retake" />
<Button android:gravity="center"
android:layout_alignParentRight="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/img_save"
android:text="@string/saveImg" android:background="@drawable/generalbutton" />
</RelativeLayout>
</RelativeLayout>
最后 2 个相对布局是可交换的并且可以很好地对齐。一次只出现一个,并在单击按钮时更改。无论如何,这里的问题是,我不得不提到以px或dp为单位的surface view的layout_height。如果我将 layout_height 设置为 fill_parent,则视图看起来非常小,只有 35% 的宽度和高度。谁能给我一个解决方案?
【问题讨论】:
-
查看这里的示例项目,该项目使用了 fill_parent 的 layout_height 和
SurfaceView: github.com/commonsguy/cw-advandroid/tree/master/Camera/Preview