2014-07-24 3 views
0

나는 안드로이드 게임용 GUI를 디자인하고 있습니다. 지금까지 나는이 사용하는 안드로이드를하려고 노력 나는이Android 앱에서 버튼 방향 변경

enter image description here

이 내 코드

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/container" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="bottom" 
    android:orientation="vertical" 
    tools:context=".Start" 
    tools:ignore="MergeRootFrame" > 

    <GridLayout 
     android:layout_width="match_parent" 
     android:layout_height="fill_parent" 
     android:columnCount="1" 
     android:padding="10dip" 
     android:rowCount="3" > 

     <Button 
      android:id="@+id/nG" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dip" 
      android:layout_marginTop="40dip" 
      android:background="@drawable/red" 
      android:onClick="nGame" 
      android:text="New" /> 

     <Button 
      android:id="@+id/hS" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dip" 
      android:layout_marginTop="20dip" 
      android:background="@drawable/green" 
      android:onClick="hScore" 
      android:text="High Scores" /> 

     <Button 
      android:id="@+id/a" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="20dip" 
      android:layout_marginTop="20dip" 
      android:background="@drawable/blue" 
      android:onClick="about" 
      android:text="About" /> 

    </GridLayout> 

</LinearLayout> 

입니다 설계하지만 난이

enter image description here

처럼 내 UI를보고 싶다 :중량. 하지만 해결책을 찾지 못했습니다.

답변

0

이것을 달성하려면 RelativeLayout을 사용할 수 있습니다. 또한 빈보기를 XML 파일 (첫 번째 하위)에 먼저 추가 할 수 있습니다. 이렇게 :

<View android:layout_height="0dp" 
android:layout_width="0dp" 
android:layout_weight="1" 
/> 

빈 공간은 사용 가능한 공간을 모두 차지하는 경향이 있습니다. 따라서 버튼을 유지 한 채 남은 공간은이보기에서 소비됩니다.

0

layout_gravity를 사용하지 마십시오. 그냥 사용하십시오

android:gravity="bottom"