CollapsingToolbarLayout日誌一直刷during second layout pass: posting in next frame

1、問題:如下:
W/View: requestLayout() improperly called by com.google.android.material.appbar.CollapsingToolbarLayout{b750378 V.ED..... ......I. 0,0-1440,1014 #7f0903e9 app:id/m_account_toolbarlayout} during second layout pass: posting in next frame

W/View: requestLayout() improperly called by ZMTextView{eb13a51 V.ED..... ......ID 720,0-720,168 #7f09059b app:id/m_title_txt} during second layout pass: posting in next frame

W/View: requestLayout() improperly called by com.google.android.material.appbar.CollapsingToolbarLayout{b750378 V.ED..... ......I. 0,0-1440,1014 #7f0903e9 app:id/m_account_toolbarlayout} during layout: running second layout pass

W/View: requestLayout() improperly called by ZMTextView{eb13a51 V.ED..... ......ID 720,0-720,168 #7f09059b app:id/m_title_txt} during layout: running second layout pass
2、原因

AppBarLayout中addOnOffsetChangedListener的回掉方法onOffsetChanged()會頻繁的爲其他控件設置屬性。

3、解決方法

在回調方法onOffsetChanged()中,避免頻繁的設置其他控件的屬性值。
比如:回掉方法中有一個屬性verticalOffset,可以根據這個值是否改變來設置控件屬性值。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章