我有一個菜單活動,其中有幾個定位按鈕。它在縱向模式下完美適合我的手機屏幕,但在橫向模式下它會被破壞。我知道,當我有固定的位置時,這將是結果。任何人都可以告訴我如何定位我的按鈕,所以我的活動也保持其形式在橫向模式?謝謝。Android:從縱向轉向橫向時定位按鈕
這裏是我的xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bezpecnost_over"
android:layout_marginLeft="30dp"
android:layout_marginTop="50dp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/kurenie_over"
android:layout_marginLeft="200dp"
android:layout_marginTop="50dp"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/osvetlenie_over"
android:layout_marginLeft="200dp"
android:layout_marginTop="200dp"
android:onClick="obrOsv" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/pohodlie_over"
android:layout_marginLeft="30dp"
android:layout_marginTop="200dp"
/>
</RelativeLayout>
這就是我教如何做到這一點的方式。除非你想根據屏幕尺寸縮放他們的位置?不要以爲這樣做或者對同一個解決方案來說工作太多。 – 2013-02-12 22:24:17
那麼你有什麼建議? – 2013-02-13 20:17:15
@MartinNemeth [this](http://developer.android.com/training/multiscreen/screensizes.html)鏈接應該更深入地討論如何支持多個screen *大小*。它討論瞭如何使用match_parent來獲得優勢以及如何使用限定符。但請記住,佈局越簡單,適應多個屏幕越容易。 – 2013-02-13 20:45:57