gpt4 book ai didi

android - 与 xml 图形布局相比,模拟器上的按钮位置不正确

转载 作者:行者123 更新时间:2023-11-30 02:33:54 26 4
gpt4 key购买 nike

所以,我试图在正确的位置放置四个按钮,但在模拟器上,这些按钮都乱七八糟。我在模拟器上使用与 xml 布局相同的设备。

XML 图形布局

http://i.imgur.com/TvngX9j.png

模拟器布局

http://i.imgur.com/10ybR6K.png

XML代码

<RelativeLayout 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:orientation="vertical"
android:background="@drawable/mainmenu" >

<Button
android:id="@+id/splay"
android:layout_width="195dp"
android:layout_height="64dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="256dp"
android:text="" />
<Button
android:id="@+id/mplay"
android:layout_width="195dp"
android:layout_height="64dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="322dp"
android:text="" />
<Button
android:id="@+id/menustat"
android:layout_width="195dp"
android:layout_height="64dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="389dp"
android:text="" />
<Button
android:id="@+id/menuset"
android:layout_width="195dp"
android:layout_height="64dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="455dp"
android:text="" />

</RelativeLayout>

知道为什么会这样吗?提前致谢。

最佳答案

您没有正确使用按钮。

为按钮提供所需的背景和文本。当前,您的按钮位于 RelativeLayout 的背景中。

关于android - 与 xml 图形布局相比,模拟器上的按钮位置不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26883052/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com