组件相关

runwu2204 Lv6

约束模式

约束模式相对于其他模式更加简单,可以直接拖动组件来改变布局。

参考使用 ConstraintLayout 构建自适应界面 | Android 开发者 | Android Developers (google.cn)

基本如下

1
2
3
4
5
6
7
<androidx.constraintlayout.widget.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">

</androidx.constraintlayout.widget.ConstraintLayout>

其所有元素都是约束在这个框架内的,需要设定相应的长宽

先点击此按钮进行消除对应的约束,不然不能正常移动组件的位置

image-20230621224501024

调整好位置后再点击自动设置约束

image-20230621224331514

基本就是这样就可以调整各个视图组件的位置。

  • 标题: 组件相关
  • 作者: runwu2204
  • 创建于 : 2023-06-21 21:50:38
  • 更新于 : 2023-06-21 22:45:29
  • 链接: https://runwu2204.github.io/2023/06/21/开发/安卓开发/组件相关/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
组件相关