Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 约束布局出错,在设备上放置textview错误_Android_Android Layout_Android Constraintlayout - Fatal编程技术网

Android 约束布局出错,在设备上放置textview错误

Android 约束布局出错,在设备上放置textview错误,android,android-layout,android-constraintlayout,Android,Android Layout,Android Constraintlayout,所以我从android studio开始,它的约束布局让我大吃一惊。起初我是…帮助。。。但之后,它看起来很不错,读了一点,我觉得我应该试试。 现在我已经完成了我的设计,并试图在我的手机上运行它,我得到了一个不同的布局,然后它应该是 我在安卓7.0中使用了lg5,同时在安卓7.1/7.0中添加了一个虚拟设备,其规格为lg5,看起来效果不错 我试着在谷歌上搜索,但找不到任何对我有帮助的答案或提示。 我向reddit android开发人员寻求有关discord的帮助,但他们也不知道,否则我应该使用相

所以我从android studio开始,它的约束布局让我大吃一惊。起初我是…帮助。。。但之后,它看起来很不错,读了一点,我觉得我应该试试。 现在我已经完成了我的设计,并试图在我的手机上运行它,我得到了一个不同的布局,然后它应该是

我在安卓7.0中使用了lg5,同时在安卓7.1/7.0中添加了一个虚拟设备,其规格为lg5,看起来效果不错

我试着在谷歌上搜索,但找不到任何对我有帮助的答案或提示。 我向reddit android开发人员寻求有关discord的帮助,但他们也不知道,否则我应该使用相对布局。但我想先知道我做错了什么

有人能帮我解决我所缺少的或做错的事情吗

“还没有帐户?”下的按钮和字段正在工作,并且像应该的那样隐藏(不可见)

编辑仍然希望有人能看到我做错了什么,这样我以后就可以学习:)

以下是我的xml:

<?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.cyberdog.mtgcollection.Login">


<EditText
    android:id="@+id/etvLoginNameDCI"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Name/DCI Number"
    android:inputType="textPersonName"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintHorizontal_bias="0.500"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="@+id/etvLoginPassword"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="16dp"
    app:layout_constraintVertical_bias="1.0" />

<EditText
    android:id="@+id/etvLoginPassword"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10"
    android:hint="Password"
    android:inputType="textPassword"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintHorizontal_bias="0.500"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="@+id/cbLoginRememberMe" />

<CheckBox
    android:id="@+id/cbLoginRememberMe"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="false"
    android:text="Remeber me"
    android:textSize="10sp"
    android:layout_marginBottom="45dp"
    app:layout_constraintBottom_toTopOf="@+id/btnLoginLogin"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintHorizontal_bias="0.328" />

<Button
    android:id="@+id/btnLoginLogin"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginEnd="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginStart="8dp"
    android:text="Log in"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    tools:layout_constraintBottom_creator="1"
    tools:layout_constraintLeft_creator="1"
    tools:layout_constraintRight_creator="1"
    android:layout_marginBottom="89dp"
    app:layout_constraintBottom_toTopOf="@+id/tvRegisterAlreadyRegister" />


<TextView
    android:id="@+id/tvRegisterAlreadyRegister"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:text="Dont have a n account yet?"
    android:textAllCaps="false"
    android:textColor="@android:color/holo_blue_bright"
    android:textSize="18sp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    tools:layout_constraintLeft_creator="1"
    tools:layout_constraintRight_creator="1"
    tools:layout_constraintTop_creator="1"
    android:layout_marginRight="8dp"
    android:layout_marginLeft="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="@+id/etvRegisterNameDCI" />

<EditText
    android:id="@+id/etvRegisterNameDCI"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="11dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:ems="10"
    android:hint="Name/DCI"
    android:inputType="textPersonName"
    android:visibility="invisible"
    app:layout_constraintBottom_toTopOf="@+id/etvRegisterEmail"
    app:layout_constraintHorizontal_bias="0.503"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<EditText
    android:id="@+id/etvRegisterEmail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="15dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:ems="10"
    android:hint="Email"
    android:inputType="textEmailAddress"
    android:visibility="invisible"
    app:layout_constraintBottom_toTopOf="@+id/etvRegisterPassword"
    app:layout_constraintHorizontal_bias="0.503"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

<EditText
    android:id="@+id/etvRegisterPassword"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="14dp"
    android:ems="10"
    android:hint="Password"
    android:inputType="textPassword"
    android:visibility="invisible"
    app:layout_constraintBottom_toTopOf="@+id/btnRegisterRegister"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent" />

<Button
    android:id="@+id/btnRegisterRegister"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Register"
    android:visibility="invisible"
    tools:layout_constraintLeft_creator="1"
    tools:layout_constraintRight_creator="1"
    tools:layout_constraintTop_creator="1"
    android:layout_marginLeft="8dp"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_marginRight="8dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    android:layout_marginBottom="42dp" />



</android.support.constraint.ConstraintLayout>


问题在于,您正在使用
visibility=“invisible”
隐藏视图,这会占用空间并将视图从屏幕中向上推。尝试使用
visibility=“gone”

@Rotwang这不是安卓工作室的事情吗?我相信这个限制是专门为android studio设计的?不,是为android设计的。Android Studio只是一个IDE。这是不相关的。为什么它会把他们推到视野之外?你可以看到它们的位置,它们在文本视图下,有足够的空间。那么他们怎么能把它们推出屏幕呢?你可以试着把它们改成总是可见的,看看它是如何在屏幕上占据空间的。DPI/字体大小在您的预览屏幕和实际设备上似乎变化很大。不是这样,我认为scren保持不变,但这些视图可见。仍然感谢您查看它:)当您将其更改为“已消失”
时,屏幕保持不变,这些视图可见吗?它应该隐藏所有视图,并使您的可见视图在屏幕限制范围内。是的,在它们再次可见之前,它确实起作用,但它也会弄乱开始屏幕,因为所有内容都在下降,而不是在顶部,而是在底部(登录部分),然后单击“链接”这将再次导致错误的屏幕布局。