我无法将按钮彼此相邻放置。我研究了这个话题,但似乎没有任何帮助。
这是我的 XML 代码:Link
下面是它现在的显示方式: My screen
如果我尝试向下移动输入按钮,清除按钮就会上升,反之亦然。我可以将按钮从一侧移动到另一侧,但绝不能与另一个按钮在同一行上
最佳答案
现在您的两个按钮是垂直方向的 LinearLayout
的元素。所有元素一个接一个地显示,因此要让它们并排显示,您只需将它们封装在水平 LinearLayout
容器中即可。
<LinearLayout android:layout-width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter"
android:id="@+id/enter"
android:layout_gravity="center"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear"
android:id="@+id/clear"
android:layout_gravity="bottom"/>
</LinearLayout>
关于Android - 彼此相邻的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20791317/