maoruibin / maoruibin/maoruibin.github.com

View 测量宽高代码

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
22
Forks
4
PR merge metrics
No merged PRs in 30d

Description

    private int measureSize(int measureSpec) {
        int specMode = MeasureSpec.getMode(measureSpec);
        int specSize = MeasureSpec.getSize(measureSpec);
        //设置一个默认值,就是这个View的默认宽度为500,这个看我们自定义View的要求
        int result = 500;
        if (specMode == MeasureSpec.AT_MOST) {//相当于我们设置为wrap_content
            Log.i(TAG+"-measure"," wrap_content");
            result = Math.min(500, specSize);
        } else if (specMode == MeasureSpec.EXACTLY) {//相当于我们设置为match_parent或者为一个具体的值
            Log.i(TAG+"-measure"," match_parent or fix size");
            result = specSize;
        }
        return result;
    }

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue contains only a Java measureSize snippet for an Android View and names no file, test, or requested change. Start by identifying whether the intended work is documentation or a code change, then locate the relevant blog entry; done requires a clearly stated outcome and a way to validate it.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
documentation, mobile
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.