为什么 layout_below 不能自动生成?而且布局有问题,东西跑到上面去了。

为什么 layout_below 不能自动生成?而且布局有问题,东西跑到上面去了。

而且每个标签下面要加上这句话 tools:ignore="MissingConstraints" 才不会报红线。

http://img1.sycdn.imooc.com//climg/5dee32540933d52713650682.jpg

<?xml version="1.0" encoding="utf-8"?>
<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"
   android:background="@drawable/bg_login"
   tools:context=".LoginActivity">

   <TextView
       android:id="@+id/id_tv_title"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_centerHorizontal="true"
       android:text="小慕餐厅"
       android:textColor="#ffffff"
       android:textSize="48dp"
       android:textStyle="bold"
       android:layout_marginTop="90dp"
       tools:ignore="MissingConstraints"
       />

   <EditText
       android:id="@+id/id_ed_username"
       android:layout_width="match_parent"
       android:layout_height="56dp"
       android:layout_below="@+id/id_tv_title"
       android:layout_marginTop="40dp"
       android:background="#44ffffff"
       android:hint="请输入账号"
       android:inputType="text"
       android:textColorHint="#ffffff"
       android:textColor="#ffffff"
       tools:ignore="MissingConstraints"
       />

   <EditText
       android:id="@+id/id_ed_password"
       android:layout_width="match_parent"
       android:layout_height="56dp"
       android:layout_below="@+id/id_ed_username"
       android:layout_marginTop="4dp"
       android:background="#44ffffff"
       android:hint="请输入密码"
       android:inputType="textWebPassword"
       android:textColorHint="#ffffff"
       android:textColor="#ffffff"
       tools:ignore="MissingConstraints"
       />

   <Button
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_below="@id/id_ed_password"
       android:layout_marginLeft="60dp"
       android:layout_marginRight="60dp"
       android:text="确定"
       tools:ignore="MissingConstraints"
       />

</androidx.constraintlayout.widget.ConstraintLayout>

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学的布局用错了哦,应该用RelativeLayout。ConstraintLayout并没有android:layout_centerHorizontal属性。祝:学习愉快

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
2.Android 网络操作与流行框架
  • 参与学习           人
  • 提交作业       220    份
  • 解答问题       1800    个

本阶段是联网及数据处理的必备技能。课程从网络基础知识到线程间协同工作、异步下载处理;从文件存储、到轻量级数据库SQLite的使用;最后利用最流程的第三方框架助你快速开发企业级APP。

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师