在约束布局中,哪个属性和哪个值可将视图放置在父视图的顶部

问题描述

在下面的约束布局中,我试图将EditText放置在最顶部,而不是垂直中心和水平中心。 是否有任何具有特定价值的属性可以实现这一目标? 代码

<androidx.constraintlayout.widget.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=".MainActivity">

<EditText
    android:id="@+id/etUserName"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint=" "
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

解决方法

删除此行

app:layout_constraintBottom_toBottomOf="parent"
,

从Edittext中删除bottomTobottomOfParent属性,该属性将附加到屏幕顶部。

,

app:layout_constraintBottom_toBottomOf =“父母”

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...