2012-10-23 17 views
5

申し訳ありませんが、私はこのような基本的な質問をしています。私は午前中にgoogleを試み、developer.android.comの文書を読んだが、解決策を見つけることができなかった。要するにAndroid GUI - ボタンを次の行に移動するにはどうすればよいですか?

、私はこのようになりますインターフェイスを作成したいと思います:

enter image description here

これは私がこれまで持っているものです。

enter image description here

、私は2つのボタンを次の行に持って行こうとしていますが、それでもまだ運がありません。 android:orientation = "horizo​​ntal"を "vertical"に変更すると、すべてが垂直に整列しました。私はButtonタグの中にandroid:orientation = "vertical"という行を表示しようとしましたが、うまくいかなかったようです。

他に何を試すことができますか?誰かが私にいくつかの指針を与えるだろうか? (私はAndroid開発と、これらのXMLのすべてのものに新しいです)。以下は


私のXMLコードです:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="horizontal" 
> 

<EditText android:id="@+id/txt_Input" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:hint="@string/txt_Input" 

     android:layout_weight="4"      
/> 
<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/btn_Send" 

     android:layout_weight="1" 

     android:onClick="sendMessage" 
/> 

<Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/btn_Send" 

     android:layout_weight="1" 

     android:onClick="sendMessage" 
/> 

</LinearLayout> 

答えて

4

ただ、RelativeLayoutを使用して、あなたのボタンは、このようなものになります。また

<Button 
    android:id="@+id/send" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_Send" 
    android:onClick="sendMessage" 
    android:layout_below="@+id/txt_Input" 
    android:layout_alignParentLeft="true"/> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/btn_Send" 
    android:onClick="sendMessage" 
    android:layout_below="@+id/txt_Input" 
    android:layout_toRightOf="@+id/send"/> 
+0

詳細な回答ありがとうございました。それはとても役に立ちました! – TATN

+0

小規模な修正、それはtoRightOfのものではなく、 –

6

それがラインアップ水平UIコンポーネントのすべてをのでHorizo​​ntalに設定向きだとあなたがのLinearLayout内の項目のすべてを持っています。必要なのは、RelativeLayoutを使用してボタンをEditTextの下のレイアウトに設定することです。

+2

を、垂直方向に向きを設定してのEditText下のボタンを囲むために、ネストされた水平直線レイアウトを使用。 – withoutclass

+2

@withoutclass:これは単に相対レイアウトよりも効率が悪いでしょう – Asahi

+0

違いはあまりありません。 – CaseyB

関連する問題