ConstraintLayout使用 笔记总结

场景:实现文本对齐。属性:layout_constraintBaseline_toBaselineOf

  • Baseline指的是文本基线:比如两个TextView的高度不一致,但是又希望他们文本对齐,这个时候就可以使用layout_constraintBaseline_toBaselineOf

角度定位。属性:app:layout_constraintCircle ; app:layout_constraintCircleAngle ;app:layout_constraintCircleRadius

  • 角度定位指的是可以用一个角度和一个距离来约束两个空间的中心。

      <TextView
              android:id="@+id/TextView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" />
    
      <TextView
          android:id="@+id/TextView2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:layout_constraintCircle="@+id/TextView1"       //参照物
          app:layout_constraintCircleAngle="120"             //角度
          app:layout_constraintCircleRadius="150dp" />       //两点之间的距离
    

属性:goneMargin:用于约束的控件可见性被设置为gone的时候使用的margin值。在参照物被设置为gone的时候见效

    layout_goneMarginStart
    layout_goneMarginEnd
    layout_goneMarginLeft
    layout_goneMarginTop
    layout_goneMarginRight
    layout_goneMarginBottom

属性:偏移:layout_constraintHorizontal_bias ; layout_constraintVertical_bias

  • 区别与margin。这两个的取值是倍数:0~1.

属性: 尺寸约束的细节:

  • 使用wrap_content的时候,以使用下列属性来控制最大、最小的高度或宽度:
    • android:minWidth 最小的宽度
    • android:minHeight 最小的高度
    • android:maxWidth 最大的宽度
    • android:maxHeight 最大的高度
      当ConstraintLayout为1.1版本以下时,使用这些属性需要加上强制约束,如下所示:
    • app:constrainedWidth=”true”
    • app:constrainedHeight=”true”
  • 使用0dp,不推荐使用match_parent

属性:layout_constraintDimensionRatio 宽高比

  • 比如正方形: app:layout_constraintDimensionRatio=“1:1”
  • 可以在前面加W或H,分别指定宽度或高度限制。 例如:
    app:layout_constraintDimensionRatio=“H,2:3” //指的是 高:宽=2:3
    app:layout_constraintDimensionRatio=“W,2:3” //指的是 宽:高=2:3

属性:layout_constraintWidth_percent 设置在布局内部的占比。比如实现在布局内部的占比一半并且居中

<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/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="textView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintWidth_percent="0.5"/>

</android.support.constraint.ConstraintLayout>

链: 当控件与控件之间相互约束的话,就可以将它们视为一条链。

  • 属性:layout_constraintHorizontal_chainStyle:改变整条链的样式,三种:
    • app:layout_constraintHorizontal_chainStyle=“packed” //打包起来:去掉了两两之间的间距
    • app:layout_constraintHorizontal_chainStyle=“spread” //(默认) 展开,两两之间平分间距
    • app:layout_constraintHorizontal_chainStyle=“spread_inside”// 展开,两两之间平分间距但是链的两端会贴边
      ps:垂直方向也有对应的三种

控件:androidx.constraintlayout.widget.Barrier 屏障,或者说参照线。

  • 据其包含的组件在某个方向最远的边缘确定。

  • 用于被参照物不确定(比如说宽高不确定,或者说显示隐藏不确定)的情况。将参照物进行打包。

    • 配合使用的属性:app:constraint_referenced_ids : 存放引用的参照物,用,隔开

        <androidx.constraintlayout.widget.Barrier
            android:id="@+id/barrier_end"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:constraint_referenced_ids="fl_screen_normal,btn_save"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />
      

控件:androidx.constraintlayout.widget.Group: 把多个控件打包,方便控制一整组控件的显示隐藏
- 配合使用的属性:app:constraint_referenced_ids : 存放引用的控件,用,隔开

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
当然,我可以为您提供关于Wireshark的使用笔记。下面是一些基本的使用说明: 1. 下载和安装:您可以从Wireshark官方网站(https://www.wireshark.org)下载适用于您操作系统的最新版本,并按照安装向导进行安装。 2. 打开Wireshark:安装完成后,打开Wireshark应用程序。在Windows上,您可以在开始菜单中找到它;在Mac上,您可以在启动台中找到它。 3. 选择网络接口:在Wireshark界面的主窗口中,选择要捕获数据包的网络接口。您可以从列表中选择一个接口,并点击“开始”按钮开始捕获数据包。 4. 捕获数据包:Wireshark将开始捕获选定网络接口上的数据包。您将看到一个实时的数据包列表,显示每个数据包的详细信息。 5. 分析数据包:您可以通过单击数据包来查看其详细信息,包括源地址、目标地址、协议等。Wireshark还提供了各种过滤和排序选项,以帮助您更好地分析数据包。 6. 应用过滤器:Wireshark支持使用过滤器来仅显示您感兴趣的数据包。您可以在“过滤器”框中输入过滤条件,并点击“应用”按钮来应用过滤器。 7. 保存和导出数据包:如果您想保存捕获的数据包以供后续分析,可以使用Wireshark的“保存”选项。您还可以导出捕获的数据包为其他格式,如PCAP、CSV等。 这是一些Wireshark的基本使用笔记,希望对您有所帮助。如果您有任何进一步的问题,请随时提问!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值