Android Guideline基准线 | 学习笔记

Guideline基准线

辅助线
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
更改背景颜色——
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android Studio中,基准线GuideLine)是一种布局工具,用于帮助开发人员在设计布局时更准确地定位控件。基准线是一条虚线,可以在布局编辑器中拖动和调整位置。基准线可以水平或垂直放置,并且可以与其他控件对齐。使用基准线可以使布局更加准确和一致。 以下是在Android Studio中使用基准线的步骤: 1. 在布局编辑器中,右键单击要放置基准线的位置,然后选择“添加水平基准线”或“添加垂直基准线”。 2. 拖动新创建的基准线到所需的位置。 3. 可以通过双击基准线来更改其属性,例如颜色和位置。 4. 将控件拖动到基准线上时,将自动将其与基准线对齐。 以下是一个使用基准线的示例布局XML代码: ```xml <androidx.constraintlayout.widget.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"> <androidx.appcompat.widget.AppCompatTextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintLeft_toLeftOf="@id/guideline" app:layout_constraintTop_toTopOf="parent" /> <androidx.appcompat.widget.AppCompatButton android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" app:layout_constraintLeft_toLeftOf="@id/guideline" app:layout_constraintTop_toBottomOf="@id/textView1" /> <androidx.constraintlayout.widget.Guideline android:id="@+id/guideline" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" app:layout_constraintGuide_percent="0.5" /> </androidx.constraintlayout.widget.ConstraintLayout> ``` 在这个示例布局中,我们创建了一个垂直基准线,并将两个控件的左侧约束设置为该基准线。这将使两个控件在布局中水平居中。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值