【发布时间】:2017-08-05 13:16:29
【问题描述】:
我是 Android 开发的新手,我正在尝试用一个按钮制作一个应用程序。
我正在使用 Intellij Design 工具进行布局,一切看起来都不错,但是当我尝试运行应用程序时,我的屏幕上没有任何按钮。
这是我的活动文件:
<?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"
-
仍然无法使用 layout_width="wrap_content"
标签: android intellij-idea