自定义了一个Toolbar,代码在github上:代码
就是一个简单的自定义view,问题是:
1、我固定了高度就一切正常。
<com.audienl.library.Toolbar
android:layout_width="match_parent"
android:layout_height="100dp"
app:toolbar_show_return="true"
app:toolbar_title="@string/app_name"/>
2、不固定高度就什么都看不见了。
<com.audienl.library.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:toolbar_show_return="true"
app:toolbar_title="@string/app_name"/>
不造哪里出错了
Toobal的onMeasure方法中,在setMeasuredDimension(width, height)
前加上measureChildren(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
layout_height使用默认值 android:layout_height="?attr/actionBarSize"
view里边没有内容,就计算不出来高度,就是看不到
测量的问题 没做AT_MOST 处理