Android View(三) 您所在的位置:网站首页 wmi控件是什么 Android View(三)

Android View(三)

2023-03-29 21:33| 来源: 网络整理| 查看: 265

    在接触View中,总是会或多或少的遇到MeasureSpec,那么今天我们就来看看MeasureSpec是什么。

一.MeasureSpec说明

1.sdk说明

A MeasureSpec encapsulates the layout requirements passed from parent to child. Each MeasureSpec represents a requirement for either the width or the height. A MeasureSpec is comprised of a size and a mode. There are three possible modes: UNSPECIFIED The parent has not imposed any constraint on the child. It can be whatever size it wants. EXACTLY The parent has determined an exact size for the child. The child is going to be given those bounds regardless of how big it wants to be. AT_MOST The child can be as large as it wants up to the specified size.

翻译:一个MeasureSpec封装传递由父控件传递到子控件的布局要求,每个MeasureSpec代表宽度或者高度的要求,一个MeasureSpec包含一个大小和模式,它有3种模式:

模式1,UNSPECIFIED,父控件不强制约束子控件,子控件可以任意大小;

模式2,EXACTLY,父控件决定子控件的大小,子控件被限制在一定的边界内,无论它有多大;

模式3,AT_MOST,子控件至多达到指定大小。

2.源码

public static class MeasureSpec { private static final int MODE_SHIFT = 30; private static final int MODE_MASK = 0x3


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有