【问题标题】:Android Studio button layout: Unexpected overlapAndroid Studio 按钮布局:意外重叠
【发布时间】:2018-07-03 00:54:17
【问题描述】:

为什么会重叠?

它在预览中的位置很好,但是当你运行应用程序时,它的布局就像你看到的那样。

【问题讨论】:

  • 请不要将代码发布为图像。相反,将代码作为文本发布在问题本身中,并使用编辑器顶部的 {} 按钮或 CTRL + K 对其进行格式化。
  • tools:layout_editor_absolute*** 仅由布局编辑器预览处理,这就是您的按钮放错位置的原因,您应该为按钮添加约束。
  • 如何给按钮添加约束?

标签: android overlap


【解决方案1】:

解决重叠的例子:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:text="Button"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"/>
</LinearLayout>

【讨论】:

    猜你喜欢
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    相关资源
    最近更新 更多