这篇文章是对layouts的整合,其中借鉴了很多很好理解的文章
android.support.constraint.ConstraintLayout
https://blog.csdn.net/weixin_42824294/article/details/92759407
android.support.constraint.Guideline
Guideline属于ConstraintLayout布局里面的一个工具类,用于辅助布局,类似为辅助线。Guideline默认是GONE不显示的。
Guideline重要的属性:
android:orientation属性来确定是横向的还是纵向的
当设置为vertical的时候,Guideline的宽度为0,高度是parent也就是ConstraintLayout的高度
同样设置为horizontal的时候,高度为0,宽度是parent的宽度layout_constraintGuide_begin,指定左侧或顶部的固定距离
如100dp,在距离左侧或者顶部100dp的位置会出现一条辅助线layout_constraintGuide_end,指定右侧或底部的固定距离
如30dp,在距离右侧或底部30dp的位置会出现一条辅助线layout_constraintGuide_percent,指定在父控件中的宽度或高度的百分比
如0.8,表示距离顶部或者左侧的80%的距离。
eg:两条50%的辅助线
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.Guideline
android:id="@+id/guideline1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<android.support.constraint.Guideline
android:id="@+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.5" />
</android.support.constraint.ConstraintLayout>
android.widget.FrameLayout
帧布局:所有的控件都会默认摆放在布局的左上角,定义在后面的控件会层叠在前面定义的控件之上,常见的一个应用场景就是"功能引导页",就是在布局最外层遮罩一层半透明的视图。或者用frameLayout装自定义view,并不常用。
android.widget.TableLayout
https://blog.csdn.net/BASIC_DU/article/details/73441167
android.widget.Space;
https://developer.android.google.cn/reference/android/widget/Space