0
我写一个相机应用中,我想在底部显示的按钮,同时在纵向视图用户视图的应用程序,并且希望展现给右侧,当使用横向视图横向和纵向视图获取按钮右侧
但在我的应用程序还是我收到按钮右侧,在这两种观点(纵向和横向)
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>
好,但我怎么知道哪一个必须显示? – Sun
Android系统决定使用哪一个。这是您的活动在您旋转设备时重新启动的原因之一。 – Ridcully
要将按钮放置在底部,请使用'android:layout_alignParentBottom'。如果你想在底部并排放置,你应该考虑将它们放置在一个水平的LinearLayout中,并使用'android:layout_alignParentBottom'将LinearLayout放置在RelativeLayout的底部。 – Ridcully