Guideline

   日期:2024-12-26    作者:la80f 移动:http://oml01z.riyuangf.com/mobile/quote/52737.html




Utility class representing a Guideline helper object for . Helper objects are not displayed on device (they are marked as ) and are only used for layout purposes. They only work within a .

A Guideline can be either horizontal or vertical:

  • Vertical Guidelines have a width of zero and the height of their parent
  • Horizontal Guidelines have a height of zero and the width of their parent

Positioning a Guideline is possible in three different ways:

  • specifying a fixed distance from the left or the top of a layout ()
  • specifying a fixed distance from the right or the bottom of a layout ()
  • specifying a percentage of the width or the height of a layout ()

Widgets can then be constrained to a Guideline, allowing multiple widgets to be positioned easily from one Guideline, or allowing reactive layout behavior by using percent positioning.

See the list of attributes in to set a Guideline in XML, as well as the corresponding , and functions in .

Example of a constrained to a vertical :

<android.support.constraint.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">

    <android.support.constraint.Guideline
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/guideline"
            app:layout_constraintGuide_begin="100dp"
            android:orientation="vertical"/>

    <Button
            android:text="Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/button"
            app:layout_constraintLeft_toLeftOf="@+id/guideline"
            android:layout_marginTop="16dp"
            app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

Set the guideline's distance from the top or left edge.

Set a guideline's distance to end.


特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


举报收藏 0评论 0
0相关评论
相关最新动态
推荐最新动态
点击排行
{
网站首页  |  关于我们  |  联系方式  |  使用协议  |  隐私政策  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号