获取按钮的风景和画象视图到右边

时间:2013-12-12 11:36:06

标签: android android-layout android-camera

我正在编写一个相机应用程序,我想在用户在纵向视图中查看应用程序时在底部显示按钮,并希望在使用横向视图时向右侧显示

但在我的应用程序中,我仍然在两个视图(纵向和横向)中将按钮设置在右侧

activity_camera.xml: -

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/splash_background" >

<FrameLayout
    android:id="@+id/camera_preview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/btnView" />

<TextView
    android:id="@+id/angel_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginTop="18dp"
    android:layout_toRightOf="@+id/camera_preview"
    android:maxLines="1"
    android:visibility="gone"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<Button
    android:id="@+id/btnView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginTop="50dp"
    android:background="@drawable/gallery" />

<Button
    android:id="@+id/btnCapture"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/camera_preview"
    android:background="@drawable/capture" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

您必须提供两个不同的布局文件,一个用于纵向,另一个用于横向。

具体来说,您应该将您的纵向布局xml放入res / layout,并将您的横向布局xml放入res / layout-land。请注意,两个文件必须具有相同的名称。

有关详细信息,请参阅http://developer.android.com/guide/practices/screens_support.html

相关问题