2012-03-12 14 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> 

しかし、これは機能しません。あなたのボタンをラップレイアウトに

android:orientation="horizontal" 

を追加

+1

エラーが発生しましたか? – iTurki

答えて

0

してみてください。 IIRCのデフォルトは垂直なので、2つのボタンを積み重ねてお互いの上に幅がゼロです。

+0

デフォルトの方向は[horizo​​ntal](http://d.android.com/reference/android/widget/LinearLayout.html)です。 –

+0

そうです。謝罪いたします。私は次のことを確認した後で修正します:私は自分の開発マシンではないが、OPの 'View'サイジングで' 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> 
関連する問題