zoukankan      html  css  js  c++  java
  • View margin 和padding, getWidth 和getMeasureWidth的区别

    Padding is the space inside the border, between the border and the actual view's content. Note that padding goes completely around the content: there is padding on the top, bottom, right and left sides (which can be independent).

    Margins are the spaces outside the border, between the border and the other elements next to this view. In the image, the margin is the grey area outside the entire object. Note that, like the padding, the margin goes completely around the content: there are margins on the top, bottom, right, and left sides.

    getwidth() is used to get width of view that has drawn like (view.getwidth() or view.getheight()).getwidth() and getHeight() will only be populated after the Layout Phase, that is after onLayout()has been called.

    getMeasureWidth() is used to get width of view that not drawn yet. like getmeasuredwidth() and getmeasureheight(). example : First call measure view.measure(0,0) and then u can use it with getmeasuredwidth() and getmeasureheight().

    should not use getwidth/getHeight the values within onMeasure() or getMeasureWidth()/getMeasureWidth(), since those are only the dimensions the View is initially offered or would like to have, not necessarily the ones it actually ends up getting.

    http://stackoverflow.com/questions/4142090/how-do-you-to-retrieve-dimensions-of-a-view-getheight-and-getwidth-always-r/4406090#4406090

  • 相关阅读:
    对拍源码QwQ
    BZOJ-3875: [Ahoi2014&Jsoi2014]骑士游戏(SPFA+DP)
    2017年10月19日23:31:57
    BZOJ-1064: [Noi2008]假面舞会 (综合性图论题)
    BZOJ-1002: [FJOI2007]轮状病毒(打表找规律or递推 + 高精度)
    BZOJ1397 Ural 1486 Equal squares
    BZOJ3417 Poi2013 Tales of seafaring
    BZOJ2286 [Sdoi2011消耗战
    BZOJ1370 [Baltic2003]Gang团伙
    BZOJ2530 [Poi2011]Party
  • 原文地址:https://www.cnblogs.com/zhuqiang/p/2952797.html
Copyright © 2011-2022 走看看