2014-06-15 4 views
0

내가 이런 각 측면에서 WASD 및 화살표가있는 '게임 패드 "를 만들기 위해 노력하고있어 필요 왼쪽 WASD와 오른쪽의 화살표가있는 동일한 "줄"안드로이드 레이아웃 생성 도움이

누군가가이 코드를 게시 할 수 있습니다. 코드가 쓰레기이고 해결책에 가깝기 때문에 게시하지 않습니다. 나는하려고하니?)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/menubg" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center|top" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="W" /> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center|top" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="A" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="S" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="D" /> 


    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center|top" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="↑" /> 

    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center|top" 
     android:orientation="horizontal" > 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="←" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="↓" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:focusable="false" 
      android:text="→" /> 


    </LinearLayout> 


</LinearLayout> 
+2

이렇게 많은 방법을 가장 우리가 수행하는 대한 기존의 레이아웃을 수정 프로그램입니다. xml 레이아웃 파일 만 코딩하면됩니다. – weston

+0

@ weston 글쎄, 그냥 그림을위한 솔루션을 만들 xml 만들지 못했지만 당신이 도움이 될 것이라고 생각한다면 게시물에 추가했습니다 – Shay

+1

상대 레이아웃은 당신이 좋아하는 일을 할 것입니다. 다른 사람들도 그렇습니다. – ChiefTwoPencils

답변

0

이 시도 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:weightSum="2" > 

    <LinearLayout 
     android:id="@+id/mainArrow" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" > 

     <LinearLayout 
      android:id="@+id/keypad" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center|top" 
       android:orientation="horizontal" > 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:focusable="false" 
        android:text="W" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center|top" 
       android:orientation="horizontal" 
       android:weightSum="9" > 

       <Button 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:focusable="false" 
        android:text="A" /> 

       <Button 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:focusable="false" 
        android:text="S" /> 

       <Button 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:focusable="false" 
        android:text="D" /> 
      </LinearLayout> 
     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/arrow" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center|top" 
       android:orientation="horizontal" > 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:focusable="false" 
        android:text="↑" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center|top" 
       android:orientation="horizontal" 
       android:weightSum="9" > 

       <Button 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:focusable="false" 
        android:text="←" /> 

       <Button 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:focusable="false" 
        android:text="↓" /> 

       <Button 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:focusable="false" 
        android:text="→" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+0

위대한 작품이지만 WASD/화살표 밑에 다른 레이아웃을 놓을 수있는 방법이 있습니까? 다른 레이아웃을 배치하는 것이 화살표 그룹의 오른쪽에 있기 때문에 – Shay

+0

내 편집보기 @Shay –

관련 문제