Nice programing

사용되지 않는 단어는 fill_parent와 match_parent의 유일한 차이점입니다.

nicepro 2020. 11. 11. 20:37
반응형

사용되지 않는 단어는 fill_parent와 match_parent의 유일한 차이점입니다.


난 둘 것을 발견 fill_parentmatch_parent같은 일을 의미한다

  • fill_parent 는 뷰가 부모의 패딩 (있는 경우)을 빼고 부모만큼 커지기를 원한다는 것을 의미합니다.
  • match_parent 는 뷰가 부모의 패딩 (있는 경우)을 빼고 부모만큼 크기를 원한다는 것을 의미합니다.

내가 찾은 유일한 차이점 fill_parent은 API 레벨 8부터 더 이상 사용되지 않고 다음으로 대체된다는 것입니다.match_parent

그러나 나는이 둘 사이에 어떤 차이도 느끼지 못했습니다. 둘 다 동일한 경우 왜 fill_parent더 이상 사용되지 않습니다. 하나는 더 이상 사용되지 않고 다른 하나는 그렇지 않다는 사실을 제외하고는 누구든지이 둘 사이의 차이점을 설명 할 수 있습니까?

http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html을 살펴 보았습니다.


당신이 말했듯이 그들은 똑같습니다. Romain Guy가 말했듯 "fill_parent"이 개발자에게는 혼란스러워서 이름을 변경 했습니다. 사실, "fill_parent"나머지 공간을 채우지 않지만 (weight 속성을 사용하기 위해) 레이아웃 부모만큼 많은 공간을 차지합니다. 이것이 새 이름이 "match_parent".


비디오의 Romain Guy에 따르면 이 단어는 동일한 행동을 나타냅니다. 그러나 많은 개발자가 fill_parent가 의미하는 바를 오해하여 별칭을 얻었습니다.


저는 Android에서 오랫동안 개발하여 이전 API에서 실행하려는 경우를 제외하고는 차이가 없다는 것을 인식했습니다. fill_parent최소 API 7로 모든 앱을 만들었 기 때문에 사용할 것입니다 . 또한 Android가 앞으로 호환되기 때문에 이것이 갈 길입니다.


기존 답변에 추가. 다음은 LayoutParamsFILL_PARENT 상수와 MATCH_PARENT 상수가 동일한 값에 매핑 되는 클래스 의 소스 코드 일부입니다 . 그래서 우리는 완전히 동일한 기능을 가지고 있습니다.

    public static class LayoutParams {
    /**
     * Special value for the height or width requested by a View.
     * FILL_PARENT means that the view wants to be as big as its parent,
     * minus the parent's padding, if any. This value is deprecated
     * starting in API Level 8 and replaced by {@link #MATCH_PARENT}.
     */
    @SuppressWarnings({"UnusedDeclaration"})
    @Deprecated
    public static final int FILL_PARENT = -1;

    /**
     * Special value for the height or width requested by a View.
     * MATCH_PARENT means that the view wants to be as big as its parent,
     * minus the parent's padding, if any. Introduced in API Level 8.
     */
    public static final int MATCH_PARENT = -1;
    ...

참고 URL : https://stackoverflow.com/questions/8516825/is-deprecated-word-the-only-difference-between-fill-parent-and-match-parent

반응형