2012-03-15 6 views
1

Buttons을 같은 줄에 나란히두고 싶습니다. ButtonEditText 옆에두고 싶습니다.동일한 행에 여러 개의 버튼/개체가 있습니다.

Eclipse 추가 기능이 있으므로 그래픽 레이아웃과 텍스트가 모두 있습니다. 이미지를 게시 할 수는 없지만 설명해 드리겠습니다 : (관련 없음), EditText, 그리고 다음 줄에 작은 레이블이 지정되지 않은 Button이 있습니다. 다음 4 개 라인 표시를 켜고 N은, W.를, E를 켜고 S를 켜고십시오 버튼입니다

그래서, 나는 제목 Button이 원하는 곳 옆에 그 EditText에이고, 나는 N, E, S 싶어 , W Buttons을 나침반과 같은 방식으로 설정해야합니다. 그러나 GUI에서 드래그하려고하면 행에 바인딩됩니다. 레이아웃을 변경하려고 할 때마다 마우스 오른쪽 버튼으로 클릭하는 객체 하나가 아니라 모든 것을 변경합니다.

어떻게 수정합니까?

답변

1

뭔가 이런 부모의 오른쪽 하단 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:text="TextView" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/textView1" 
     android:text="TextView" /> 

    <EditText 
     android:id="@+id/editText1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/textView2" 
     android:layout_toLeftOf="@+id/button1" > 
    </EditText> 

    <Button 
     android:id="@id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_below="@id/textView2" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/editText1" 
     android:layout_centerHorizontal="true" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/button2" 
     android:layout_toLeftOf="@id/button2" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/button2" 
     android:layout_toRightOf="@id/button2" 
     android:text="Button" /> 

    <Button 
     android:id="@+id/button5" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/button4" 
     android:layout_toLeftOf="@id/button4" 
     android:text="Button" /> 

</RelativeLayout> 
+0

감사합니다, 이것은 매우 도움이되었다, 지금은 XML의 내 그래픽 레이아웃보기 I가 원하는 단지로 표시됩니다. (몇 가지 버튼을 더 추가했습니다.) 그러나 현재 자바 파일에는 main을 참조하는 모든 것에 오류가 있습니다. "setContentView (R.layout.main);"아래에서 그것은 오류를 말한다 : "메인은 해결할 수 없거나 필드가 아니다." 내 XML 파일에 오류가 표시되지 않으며 Eclipse 다시 시작하려고했는데 잘못 찾은 것이 없습니다. 어떤 제안? 감사! – Zeldarulah

+0

@Zeldarulah 프로젝트 ('Project-> Clean' 메뉴)를 청소하고 패키지에서 올바른'R' 클래스 ('CTRL + SHIFT + O')를 가져 왔는지 확인하십시오. R;'). – Luksprog

+0

"android.R; 가져 오기"가 있지만 프로젝트 -> 정리 및 Ctrl + Shift + O를 모두 시도했지만 변경되지 않았습니다. "android.R을 가져와야합니다."; 뭔가 다른 것인가? 다시 한번 감사드립니다. – Zeldarulah

0

나는 xml이 없다면 정말로 말할 수 없지만 compas와 같은 방식으로 버튼을 배치하려면 quadrate relative layout을 만들고 그 위에 버튼을 놓은 다음 상단, 왼쪽에 버튼을 배치해야합니다 ,

관련 문제