我是Android开发新手,我试图用一个按钮创建应用程序。Android - 按钮不会出现
我使用Intellij设计工具来使我的布局和一切似乎确定,但是当我尝试运行该应用程序时,我的屏幕上没有按钮。
这里是我的活动文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.button test.MainActivity" tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
<Button
android:text="Hello"
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:layout_constraintTop_creator="1" tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1" tools:layout_constraintLeft_creator="1"/>
</android.support.constraint.ConstraintLayout>
编辑: 更改的Android:layout_width = “0dp” 到Android:layout_width = “WRAP_CONTENT” 不会改变任何东西。
的android:layout_width = “0dp”=>的android:layout_width = “WRAP_CONTENT” –
你的android:layout_width = “0dp” – Mike
还没与layout_width = “WRAP_CONTENT” 仍在工作 – Itega