2012-03-12 5 views
0

나는 Finger Paint API 데모를 시험해보고 있는데 버튼을 추가하려고합니다. 나는 포함했다보기로 레이아웃에 버튼 추가

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <view 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.triopsys.imosandroid.ViewControllers.SignatureViewController$MyView" /> 

</LinearLayout> 

내 레이아웃 xml에서이보기의 상단이나 하단에 단추를 추가 할 수 없다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

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

     <Button 
      android:id="@+id/buttonCancel" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Cancel" > 
     </Button> 

     <Button 
      android:id="@+id/buttonOk" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="OK" > 
     </Button> 
    </LinearLayout> 

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

     <view 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      class="com.triopsys.imosandroid.ViewControllers.SignatureViewController$MyView" /> 
    </LinearLayout> 

</LinearLayout> 

하지만 이것은 작동하지 않습니다.

+1

어떤 종류의 오류가 발생하고 있습니까? – iTurki

답변

0

시도하여 버튼을 배치 레이아웃에

android:orientation="horizontal" 

를 추가. IIRC는 기본값이 세로이므로 너비가 0 인 두 개의 버튼을 서로 쌓아 올리고 있습니다.

+0

기본 방향은 [가로] (http://d.android.com/reference/android/widget/LinearLayout.html)입니다. –

+0

그렇습니다. 내 사과. 나는 다음을 확인하면 게시물을 고칩니다. 나는 내 컴퓨터에 있지 않지만, OPs의'보기'크기 조정에 대해서'match_parent'로 설정 한 다음,'LinearLayout' 그것은'wrap_content'로 설정되어 있으므로, 어떤 높이가 걸립니까? 전체 화면? – CjS

0

하면이 오류를 받고 있지 않은 경우 :

은 내가 문제가 버튼 '폭 값을 것 같다. 변경하려면 wrap_content

0

정확히 작동하지 않는 기능은 무엇입니까? 나는이 레이아웃을 시험해 보았는데 컴파일하고 올바르게 표시한다.

"작동하지 않는"은 "내 사용자 정의보기가 전체 화면을 차지하지 않습니다"라는 의미이고 linearLayout2을 제거합니다. 어쨌든 중복되어 삭제 될 수 있습니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

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

     <Button 
      android:id="@+id/buttonCancel" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Cancel" > 
     </Button> 

     <Button 
      android:id="@+id/buttonOk" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="OK" > 
     </Button> 
    </LinearLayout> 

    <view 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.triopsys.imosandroid.ViewControllers.SignatureViewController$MyView" /> 

</LinearLayout> 
관련 문제