问题描述
我是初学者,这是我运行应用程序时的外观.我正在使用最新版本的Android Studio.默认情况下,约束布局是屏幕截图
I am a beginner this is what it looks when i run my app . i am using latest version of Android studio. having constraint Layout as default here are the screenshots
这就是显示的
https://drive.google.com/file/d/0B-ydaOiOKnYnOG1oODVoZEtwRzA/view?usp = drivesdk
这就是我要设计的东西
https://drive.google.com/file/d/0B-ydaOiOKnYnQ2NKSXdZencxYk0/view?usp = drivesdk
可以提供帮助.
推荐答案
这是您要使用ConstraintLayout实现的目标
Here's what you want to achieve using ConstraintLayout
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/email_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EMAIL"
android:textSize="22sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.2" />
<EditText
android:id="@+id/email_input"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_margin="16dp"
android:background="@android:color/white"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/email_label" />
<TextView
android:id="@+id/pwd_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="PWD"
android:textSize="22sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/email_input" />
<EditText
android:id="@+id/pwd_input"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_margin="16dp"
android:background="@android:color/white"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pwd_label" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="LOGIN"
android:textSize="16sp"
android:layout_margin="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pwd_input" />
</android.support.constraint.ConstraintLayout>
在电子邮件标签的小部件中,您还可以删除"layout_constraintVertical_bias"和"layout_constraintBottom_toBottomOf"属性并固定上边距.
也可以使用Chains来完成.
确保您使用的是ConstraintLayout 1.0.2.
In the email label's widget, You can also remove the "layout_constraintVertical_bias" and "layout_constraintBottom_toBottomOf" attributes and fix a top margin.
This can be done using Chains too.
Make sure you are using ConstraintLayout 1.0.2.
您可以阅读有关ConstraintLayout的出色教程
使用ConstraintLayout构建界面
You can read this great tutorial about ConstraintLayout
Building interfaces with ConstraintLayout
希望这会有所帮助!
这篇关于所有项目合并到约束布局Android Studio的左上方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!