我想把这两个按钮放在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. 如何在boxLayout中的两个按钮之间添加空格?
- 22. 如何在JToolBar中的两个按钮之间添加空隙?
- 23. 如何在android中执行同一活动中的两个按钮?
- 24. 在PrefrenceScreen中添加一个按钮:Android
- 25. 的Android - 添加按钮,股票相机
- 26. 如何在alertdialog按钮中添加按钮点击效果android
- 27. Android:如何将画布添加到FrameLayout?
- 28. 如何在一个按钮中添加一个ImageButton android
- 29. 你如何有两个按钮保存到android中的相同数据文件?
- 30. 如何使用CSS QT在按钮中添加两个图像?