android——layout边走边看

这篇文章是对layouts的整合,其中借鉴了很多很好理解的文章

在这里插入图片描述

android.support.constraint.ConstraintLayout

https://blog.csdn.net/weixin_42824294/article/details/92759407

android.support.constraint.Guideline

Guideline属于ConstraintLayout布局里面的一个工具类,用于辅助布局,类似为辅助线。Guideline默认是GONE不显示的。

Guideline重要的属性:

  1. android:orientation属性来确定是横向的还是纵向的
    当设置为vertical的时候,Guideline的宽度为0,高度是parent也就是ConstraintLayout的高度
    同样设置为horizontal的时候,高度为0,宽度是parent的宽度
  2. layout_constraintGuide_begin,指定左侧或顶部的固定距离
    如100dp,在距离左侧或者顶部100dp的位置会出现一条辅助线
  3. layout_constraintGuide_end,指定右侧或底部的固定距离
    如30dp,在距离右侧或底部30dp的位置会出现一条辅助线
  4. 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值