我想問你,我怎麼能把兩個EditText
放在同一行?如何把兩個EditText放在同一行
10
A
回答
16
這給一個鏡頭:
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
此外,你應該嘗試接受的答案,如果你得到一個回答你的問題。你會更有可能得到更多/更好的迴應。
5
有多種方法,這裏有2
有水平的LinearLayout
分配android:orientation="horizontal"
你的外LinearLayout
。通過這種方式,此佈局的所有子元素都將相互對齊。
半佈局:
<LinearLayout android:orientation="horizontal">
<EditText />
<EditText />
</LinearLayout>
隨着RelativeLayout的
使用android:layout_toLeftOf="@id/otheredittext"
或android:layout_toRightOf="@id/.."
告訴EditTexts之一,它屬於右/左另一個和對齊第一個相對於父母(RelativeLayout
),使用android:layout_alignParentTop="true"
,與左側,右側或底部相同。
半佈局:
<RelativeLayout>
<EditText android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:id="@+id/edittext1"
/>
<EditText android:layout_toRightOf="@id/edittext1" />
</RelativeLayout>
(另請注意,您在android:id
分配首次的ID時,當您通過android:layout_to...
從佈局引用它一個+id
,它只是id
)
1
對於線性佈局這將是如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="100dip">
<requestFocus></requestFocus>
</EditText>
<EditText android:layout_height="wrap_content" android:id="@+id/editText2" android:layout_width="100dip"></EditText>
</LinearLayout>
對於相對佈局將是如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="100dip">
<requestFocus></requestFocus>
</EditText>
<EditText android:layout_height="wrap_content" android:layout_width="100dip" android:id="@+id/editText2" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"></EditText>
</RelativeLayout>
相關問題
- 1. 把兩個表放在同一行html
- 2. 如何把EditText和Button放在一起?
- 3. 如何把「表單」放在同一行?
- 4. 把兩列放到一個
- 5. 把兩個ID放在一個href
- 6. 不能把兩個div放在一起
- 7. 如何把兩個jasperReports放在一個zip文件中下載?
- 8. html把divs放在同一行
- 9. 把兩個按鈕放到一個UITableViewCell
- 10. 我該如何把這兩個div放在一起呢?
- 11. 如何把兩個查詢放在一起?
- 12. 如何把2個div放在一起?
- 13. 把兩個數組放到Jtable行
- 14. 如何將兩個按鈕放在Android中的同一行上
- 15. 如何將兩個按鈕放在同一行
- 16. Android_RelativeLayout - 如何將兩個元素放在同一行上?
- 17. 不能把兩個函數的輸出放在一行中嗎?
- 18. 如何把一個元素放在不同的地方(響應)
- 19. 把兩個或三個圖像放在一行中的兩列文章中
- 20. 把EditText放在軟鍵盤上面
- 21. 如何把在同一水平對齊兩個按鈕?
- 22. 如何把這兩個放在同一條線上? (一個居中,一個右對齊)
- 23. 如何把兩個java swing JPanels放在一起並且有一個表格呢?
- 24. 把兩個輸入文本在同一行
- 25. mySQL把同一個id的結果放在同一列
- 26. 如何把相同的兩個屬性一個HTML元素?
- 27. 如何把空格放在一個新的行html5?
- 28. 如何放置一個容器(兩行)與兩個容器(兩個不同的行)在自舉?
- 29. 如何把數組值放在同一行的不同列中csv
- 30. 如何放置兩個I幀的同一行
在同一行的......到底是什麼?一個listview,一個gridview,一個簡單的基本視圖? – Kheldar