有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

安卓 studio中的java合并内容运行时错误

我对安卓 studio中的XML文件有问题,我对它很陌生,我想设计一个文本,文本下面有两个按钮,但当它运行位于(0,0)位置的所有内容时,只有最后一个按钮出现在设备中 这是我的密码

<?xml version="1.0" encoding="utf-8"?>
<安卓.support.constraint.ConstraintLayout 
xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:app="http://schemas.安卓.com/apk/res-auto"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
tools:context="com.example.tabarek.mysecondapplication.MainActivity">

<TextView
    安卓:layout_width="wrap_content"
    安卓:layout_height="wrap_content"
    安卓:text="Information!"
    安卓:id="@+id/hello"
     />

<Button
    安卓:id="@+id/button"
    安卓:layout_width="fill_parent"
    安卓:layout_height="wrap_content"
    安卓:onClick="SayHi"
    安卓:text="About Me"
    安卓:layout_below="@+id/hello"
     />
<Button
    安卓:id="@+id/button2"
    安卓:layout_width="fill_parent"
    安卓:layout_height="wrap_content"
    安卓:onClick="SayHi"
    安卓:text="My Email"
    安卓:layout_below="@+id/button"
    />
    </安卓.support.constraint.ConstraintLayout>

最后,, 结果是这样的 enter image description here

你能帮帮我吗


共 (1) 个答案

  1. # 1 楼答案

    尝试使用LinearLayout

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
    
        <TextView
            android:id="@+id/hello"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Information!" />
    
        <Button
            android:id="@+id/button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="SayHi"
            android:text="About Me" />
    
        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="SayHi"
            android:text="My Email" />
    </LinearLayout>