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