2012-08-26 96 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