<?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"><ImageVIEw androID:ID="@+ID/imageVIEw" androID:layout_wIDth="0dp" androID:layout_height="190dp" androID:layout_marginleft="16dp" androID:layout_marginStart="0dp" androID:layout_margintop="0dp" androID:contentDescription="dummy" androID:scaleType="centerCrop" androID:src="@drawable/lion" app:layout_constraintBottom_creator="1" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintleft_creator="1" app:layout_constraintleft_toleftOf="parent" app:layout_constraintRight_creator="1" app:layout_constraintStart_toStartOf="parent" app:layout_constrainttop_creator="1" app:layout_constrainttop_totopOf="parent" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="16dp" /><androID.support.design.Widget.TabLayout androID:ID="@+ID/tabLayout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_margintop="0dp" app:layout_constrainttop_toBottomOf="@+ID/imageVIEw" tools:layout_editor_absoluteX="8dp"> <androID.support.design.Widget.TabItem androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="abc" /> <androID.support.design.Widget.TabItem androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="xyz" /></androID.support.design.Widget.TabLayout><androID.support.design.Widget.TextinputLayout androID:ID="@+ID/til_et_email" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_marginEnd="24dp" androID:layout_marginStart="24dp" androID:layout_margintop="16dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constrainttop_toBottomOf="@+ID/tabLayout"> <androID.support.design.Widget.TextinputEditText androID:ID="@+ID/et_email" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center_horizontal" androID:hint="@string/et_email_hint" /></androID.support.design.Widget.TextinputLayout><androID.support.design.Widget.TextinputLayout androID:ID="@+ID/til_password" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_marginEnd="24dp" androID:layout_marginStart="24dp" androID:layout_margintop="0dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constrainttop_toBottomOf="@+ID/til_et_email"> <EditText androID:ID="@+ID/et_password" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center_horizontal" androID:hint="@string/et_password_hint" /></androID.support.design.Widget.TextinputLayout><button androID:ID="@+ID/button" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_marginEnd="24dp" androID:layout_marginStart="24dp" androID:layout_margintop="16dp" androID:text="@string/bt_sign_in" app:layout_constraintEnd_toEndOf="@+ID/til_password" app:layout_constraintStart_toStartOf="@+ID/til_password" app:layout_constrainttop_toBottomOf="@+ID/til_password" tools:layout_editor_absoluteY="403dp" /><TextVIEw androID:ID="@+ID/tv_forgot_password" androID:layout_wIDth="0dp" androID:layout_height="wrap_content" androID:layout_marginEnd="8dp" androID:layout_marginStart="8dp" androID:layout_margintop="8dp" androID:autoSizeMaxTextSize="41sp" androID:autoSizeMinTextSize="17sp" androID:autoSizeStepGranularity="2sp" androID:autoSizeTextType="uniform" androID:gravity="center" androID:text="@string/tv_forgot_password" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constrainttop_toBottomOf="@+ID/button" />
在上面的部分中,我将边缘值设置为硬编码.所以,如果我在5.0屏幕尺寸上运行代码就可以了.但是,如果我在5.5屏幕尺寸上运行它,而不是调整边距,它会在底部留下空白区域.
解决方法 使用“指南”约束可根据不同的屏幕大小为视图提供百分比.<androID.support.constraint.GuIDeline androID:ID="@+ID/top_guIDeline" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:orIEntation="horizontal" app:layout_constraintGuIDe_percent="0.09" />
请参阅以下谷歌链接.
https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html
以上是内存溢出为你收集整理的android – 不同屏幕尺寸的约束布局全部内容,希望文章能够帮你解决android – 不同屏幕尺寸的约束布局所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)