2012-04-04 3 views
0

마지막 단추가 화면 맨 아래에 고정되도록 버튼을 나열하고 싶습니다. 어떻게하면됩니까? 내 이해에서, LinearLayout는 나에게 버튼의 '목록'을 줄 것이다. 그러나 그것은 꼭대기에 고정 될 것이다. RelativeLayout은 다른 한편으로는 맨 아래로 고정시킬 수는 있지만 각 요소는 다음 요소에 대한 참조를 가져야하며 XML 파일은 역순으로 배치되므로 참조가 유효합니다.RelativeLayout을 사용하지 않고 화면 맨 아래에 요소를 첨부하십시오.

어떻게 접근해야합니까?

편집 : 죄송합니다, 이것은 내가 찾고있을 것입니다 무슨 약이 될 것입니다 -

screenshot

+0

우리가이 권리를 얻는 것을 확인하기 위해 내가 좋아하는 그래픽 편집기 (페인트, 김프 ... 등등)를 터뜨린 다음 원하는 것을 그려서 게시물에 이미지로 추가 할 것을 제안합니다. 상대방의 레이아웃은 적절하게 들리지만 공동체의 다른 사람들도 우리가 올바른 조언을하기를 원할 것이라고 확신합니다. –

답변

1

질문을 정확하게 이해하는 데 어려움이 있습니다. 그러나 원하는 것은 화면 맨 아래에 고정 된 단추의 가로 목록입니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <!-- put your other views in here --> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/button_cancel" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:padding="5dp" 
      android:text="cancel" /> 

     <Button 
      android:id="@+id/button_ok" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:padding="5dp" 
      android:text="ok" /> 
    </LinearLayout> 
</LinearLayout> 
+0

android : layout_gravity = "bottom"- 당연히! – stephenfin

2
당신은 나머지 공간을 모두 차지하기 위해 하나의 무게와 여분의 LinearLayout을 추가하는 시도 할 수

하고, 활동의 하단에 버튼의 목록을 밀어 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    android:id="@+id/widget32" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
<LinearLayout 
android:layout_width="fill_parent" 
    android:layout_height="0dp" 
android:layout_weight="1"> 
</LinearLayout> 
<Button 
    android:id="@+id/widget33" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Button" /> 
</LinearLayout> 

샘플 XML이 활동의 ​​맨 아래에있는 LinearLayout에 의해 추진됩니다 하나의 버튼입니다; 루트 레이아웃 역시 선형입니다.

+0

감사! 'RelativeLayout'없이 화면 아래쪽에 버튼을 위치 시키려면 잘 작동했습니다 – Konayuki

관련 문제