我想把這兩個按鈕放在framelayout中。我可以用RelativeLayout來實現,使用左邊的屬性,但是使用Framelayout,我沒有找到任何這樣的屬性。如何將上方的同一行中的拖曳按鈕對齊?android:如何在framelayout中添加兩個按鈕相同的行?
-3
A
回答
1
嘗試使用的LinearLayout封裝的按鈕,這樣的:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:id="@+id/main">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button2" />
</LinearLayout>
</FrameLayout>
0
您可以使用layout_gravity屬性:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:layout_gravity="left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button 1"
android:id="@+id/button_1" />
<Button
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button 2"
android:id="@+id/button_2" />
</FrameLayout>
值重力可以組合,如:left|top
,left|center_vertical
,left|bottom
, 等等。
你也可以使用左邊距值的第二個按鈕,例如:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="200dp"
android:text="button 2"
android:id="@+id/button_2" />
...或者,爲什麼不利用重力和保證金的權利,以放置按鈕數量DP的從右邊距
<Button
android:layout_gravity="right"
android:layout_marginRight="200dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button 2"
android:id="@+id/button_2" />
相關問題
- 1. 添加兩個在FrameLayout中相互接觸的按鈕
- 2. 如何在Android的同一行中添加兩個按鈕?
- 3. 如何在面板的同一行添加兩個按鈕?
- 4. 如何將兩個按鈕放在Android中的同一行上
- 5. 在自定義相機上添加按鈕FrameLayout
- 6. 如何在Android中添加相機預覽框中的按鈕?
- 7. 如何在單個屏幕中添加兩個FrameLayout
- 8. 同時添加兩個圖像按鈕
- 9. 如何在android中添加兩個圖像視圖和兩個按鈕
- 10. 如何在android中的相同ListPreference中添加單選按鈕和複選框?
- 11. Android:如何將兩個按鈕添加到操作欄中
- 12. 如何在android中添加按鈕?
- 13. 如何在android中添加按鈕?
- 14. 如何在ActionBar(Android)中添加按鈕?
- 15. 如何在Android中的線性視圖中的欄中添加兩個按鈕?
- 16. 如何添加兩個recyclerview相同fragmnets
- 17. 如何在JTable中添加新行,同時按一下按鈕
- 18. 如何在mvc中的grid.mvc控件中添加兩個按鈕
- 19. Android。兩個完全相同的按鈕有不同的陰影
- 20. FrameLayout中的Android按鈕佈局
- 21. 如何在JToolBar中的兩個按鈕之間添加空隙?
- 22. 如何在boxLayout中的兩個按鈕之間添加空格?
- 23. 如何在android中執行同一活動中的兩個按鈕?
- 24. 在PrefrenceScreen中添加一個按鈕:Android
- 25. 的Android - 添加按鈕,股票相機
- 26. 如何在alertdialog按鈕中添加按鈕點擊效果android
- 27. Android:如何將畫布添加到FrameLayout?
- 28. 如何在一個按鈕中添加一個ImageButton android
- 29. 你如何有兩個按鈕保存到android中的相同數據文件?
- 30. 如何使用CSS QT在按鈕中添加兩個圖像?