2012-08-26 32 views
1

我很好,用於這個開始的應用程序的Java我試圖。但是這個XML仍然讓我有些擔心。我已經包含了一個我想要實現的圖片: enter image description hereAndroid佈局的幫助 - 屏幕的一半應該倒過來

這裏是我到目前爲止的代碼。我很高興與它出來的樣子,我只需要知道如何扭轉上半年:

<LinearLayout 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"> 

    <LinearLayout 
     android:id="@+id/opponent" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:gravity="bottom" 
     android:layout_weight="1" 
     android:clickable="false" > 

     <RelativeLayout 
      android:id="@+id/opPlus" 
      android:layout_width="wrap_content" 
      android:layout_height="50dp" 
      android:layout_weight="0.5" 
      android:clickable="true" > 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/opMinus" 
      android:layout_width="wrap_content" 
      android:layout_height="50dp" 
      android:layout_weight="0.5" 
      android:clickable="true" > 

     </RelativeLayout> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/player" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:gravity="bottom" 
     android:layout_weight="1" 
     android:clickable="false" > 

     <RelativeLayout 
      android:id="@+id/plPlus" 
      android:layout_width="wrap_content" 
      android:layout_height="50dp" 
      android:layout_weight="0.5" 
      android:clickable="true" > 

     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/plMinus" 
      android:layout_width="wrap_content" 
      android:layout_height="50dp" 
      android:layout_weight="0.5" 
      android:clickable="true" > 

     </RelativeLayout> 

    </LinearLayout> 

在此先感謝大家!

回答

2

只需添加:

android:rotation="180" 

到您要旋轉視圖或ViewGroup中。在這種情況下,LinearLayout@+id/opponent

編輯的ID:例:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    > 
    <RelativeLayout 
    android:id="@+id/opponent" 
    android:rotation="180" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:background="#FF8833" 
    > 
    <View 
     android:id="@+id/emptyview" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_centerInParent="true" 
     /> 
    <Button 
     android:layout_height="50dp" 
     android:layout_width="match_parent" 
     android:layout_toLeftOf="@id/emptyview" 
     android:layout_alignParentBottom="true" 
     android:background="#999999" 
     android:text="Button 1" 
     /> 
    <Button 
     android:layout_height="50dp" 
     android:layout_width="match_parent" 
     android:layout_toRightOf="@id/emptyview" 
     android:layout_alignParentBottom="true" 
     android:background="#888888" 
     android:text="Button 2" 
     /> 
    </RelativeLayout> 
    <RelativeLayout 
     android:id="@+id/opponent" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:background="#33FF33" 
     > 
    <View 
     android:id="@+id/emptyview" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_centerInParent="true" 
     /> 
    <Button 
     android:layout_height="50dp" 
     android:layout_width="match_parent" 
     android:layout_toLeftOf="@id/emptyview" 
     android:layout_alignParentBottom="true" 
     android:background="#999999" 
     android:text="Button 1" 
     /> 
    <Button 
     android:layout_height="50dp" 
     android:layout_width="match_parent" 
     android:layout_toRightOf="@id/emptyview" 
     android:layout_alignParentBottom="true" 
     android:background="#888888" 
     android:text="Button 2" 
     /> 
    </RelativeLayout> 
</LinearLayout> 

結果:

enter image description here

+0

我不知道爲什麼,但是當我把它放在和重新加載圖形界面,它不顯示任何更改。 2個按鈕仍然坐在屏幕中央 – Psest328

+1

適合我。我編輯了一個我做過的例子。 – kcoppock

+0

我明白了。奇怪的。我得到:錯誤。在包「android」中找不到屬性「rotation」的資源 – Psest328