开发者

how to order the différent object in interface

I want to have an EditText and button in the same row.

S开发者_Python百科o why I put <LinearLayout android:orientation="horizontal"...>

But I have also a TextView and I didn't want that TextView appear in the same row as the EditText and the button.

Thanks for helping me.


You can do this in many ways.

  1. Linear layout
  2. Relative Layout
  3. Table Layout.

Using linear layout - You can put one linear layout 'A' at top and set its orientation "vertical". Now put two child nodes inside it one new linear layout 'B' and one textview. In new linear layout you set its orientation "horizontal" and then add button, edittext in it.

Following is code:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <EditText
            android:text="EditText"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:width="250dp"></EditText>
        <Button
            android:text="Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"></Button>
    </LinearLayout>
    <TextView
        android:text="TextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </TextView>
</LinearLayout>


Try using RelativeLayout in your xml.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜