listenzz/AndroidNavigation

Toolbar Title layoutParams

ysmintor opened this issue · 2 comments

LayoutParams layoutParams = new LayoutParams(-2, -2, Gravity.CENTER_VERTICAL | Gravity.START);
从下面函数找到的,对于填入-2的依据是什么?

protected TextView getTitleView() {
        if (titleView == null) {
            titleView = new TextView(getContext());
            LayoutParams layoutParams = new LayoutParams(-2, -2, Gravity.CENTER_VERTICAL | Gravity.START);
            layoutParams.leftMargin = getContentInset();
            addView(titleView, layoutParams);
        }
        return titleView;
    }

-2 就是 wrap_content

就是 ViewGroup.LayoutParams.WRAP_CONTENT

好的,了解了!