【发布时间】:2011-07-14 19:41:43
【问题描述】:
我正在尝试开发具有 3 个选项卡的应用程序,以便第一个选项卡启用相机并捕获图像。到目前为止,我的相机有 2 个问题:
我希望相机锁定为纵向或横向模式。如果我将相机锁定为纵向,则图像似乎已旋转,并且我已使用 camera.parameters 尝试了几乎所有方法,但无法修复它。如果我将相机锁定在横向模式,那么问题在于选项卡菜单也将方向更改为横向。有没有办法只在该选项卡内更改方向并将选项卡菜单保持为纵向模式?
图像以某种方式被拉伸。我猜问题是相机使用全屏的高度和宽度,但我的应用程序试图将相机预览放在比屏幕小的框架布局内,因为选项卡菜单,所以图像被拉伸。有什么办法可以解决这个问题并显示带有标签菜单的实际相机预览?
我使用 1 个活动来创建 3 个选项卡并使用此布局:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</TabHost>
我为每个标签使用 1 个活动。特别是对于第一个选项卡(相机),我在以下布局中使用 preview.class:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout" android:orientation="vertical" android:layout_height="wrap_content" android:layout_width="wrap_content">
<FrameLayout android:layout_weight="1" android:id="@+id/preview" android:layout_gravity="fill_vertical" android:fitsSystemWindows="true" android:layout_height="wrap_content" android:layout_width="wrap_content">
</FrameLayout>
<Button android:text="Click" android:id="@+id/buttonClick" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_gravity="center"></Button>
</LinearLayout>
【问题讨论】:
标签: android tabs camera orientation