2011-10-24 5 views
0

상대 레이아웃을 사용하여 버튼 기반 메뉴를 만들려고합니다. 나는 이미 있던 세 개의 버튼 아래에 또 하나 개의 버튼을 추가하려면 내가 시도버튼이 화면에서 벗어납니다.

android:below="" 
android:above="" 
android:toLeftOf="" 
android:toRightOf="" 

명령

를 사용하여 그리드 형성을 배치하려고하지만, 대신 버튼의 부모에 맞게 크기를 조정하고 대신 네 번째 버튼이 화면 가장자리 아래로 떨어집니다. 작은 화면에서 단추가 누락되는 것을 원하지 않기 때문에이 문제를 해결할 수 있습니까? 여기에 그들이 시작의 메뉴 시스템에서 더 깊이 숨겨져 있기 때문에 가시성은 기본적으로 사라로 설정되어 내 레이아웃

<RelativeLayout android:id="@+id/level1layout" 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:layout_gravity="center_horizontal"> 

<Button android:id="@+id/OneLevel1Button" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:layout_marginRight="10dp" 
android:layout_marginLeft="10dp" 
android:layout_marginBottom="10dp" 
android:layout_marginTop="10dp" 
android:text="1" 
android:textSize="25dp" 
android:background="@drawable/warpbutton" 
android:visibility="gone"/> 

    <Button android:id="@+id/OneLevel2Button" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:layout_marginRight="10dp" 
android:layout_marginLeft="10dp" 
android:layout_marginBottom="10dp" 
android:layout_marginTop="10dp" 
android:layout_below="@id/OneLevel1Button" 
android:text="2" 
android:textSize="25dp" 
android:background="@drawable/warpbutton" 
android:visibility="gone"/> 

<Button android:id="@+id/OneLevel3Button" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:layout_marginRight="10dp" 
android:layout_marginLeft="10dp" 
android:layout_marginBottom="10dp" 
android:layout_marginTop="10dp" 
android:layout_below="@id/OneLevel2Button" 
android:text="3" 
android:textSize="25dp" 
android:background="@drawable/warpbutton" 
android:visibility="gone"/> 

<Button android:id="@+id/OneLevel4Button" 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:layout_marginRight="10dp" 
android:layout_marginLeft="10dp" 
android:layout_marginBottom="10dp" 
android:layout_marginTop="10dp" 
android:layout_below="@id/OneLevel3Button" 
android:text="4" 
android:textSize="25dp" 
android:background="@drawable/warpbutton" 
android:visibility="gone"/> 

</RelativeLayout> 

입니다.

답변

1

GridLayout 사용을 고려 했습니까? http://developer.android.com/reference/android/widget/GridLayout.html

OP의 제안에 따라 GridView에 대해 custom ButtonAdapter을 생성하는 매우 유용한 사이트입니다.

+0

쉽게 가시성을 설정할 수 있으며 동일한 활동에서 둘 이상의 실행 가능성이있을 수 있습니까? 오, 그리고 [여기] (http://developer.android.com/resources/tutorials/views/hello-gridview.html)에서 사용 된 이미지를 버튼으로 대체 할 수 있습니까? – Jack

+0

여기서 backpedal하고 제공 할 원래 링크를 제공 할 예정입니다 - http://developer.android.com/guide/tutorials/views/hello-gridview.html 캡쳐 화면이나 모의 사례를 게시 할 수 있습니까? 당신이 달성하려고하는 것의 위로? –

+0

정말 그걸 말하고 싶지 않은만큼 나는 그 화가 조류 레벨 선택 메뉴 같아요. 그리드 레이아웃에서 작은 번호의 정사각형을 가진 것. – Jack

관련 문제