android webview ZoomButtonsController 導致android.view.WindowLeaked 問題徹底解決

來源:互聯網
上載者:User

標籤:des   android   style   class   blog   code   

Activity has leaked window android.widget.ZoomButtonsController that was originally added here android.view.WindowLeaked:

引起這個錯誤的原因是:

發現是webview的 ZoomButton,也就是那兩個放大和縮小的按鈕,導致的。如果設定為讓他們出現,並且可以自動隱藏,那麼,由於他們的自動隱藏是一個漸層的過程,所以在逐漸消失的過程中如果調用了父容器的destroy方法,就會導致Leaked。所以解決方案是,在destroy之前,先讓他倆立馬消失。至於立馬消失的方法,網上大多抄來抄去,沒有效果。我的解決辦法是,在finish掉此activity時,把子view 全部remove掉。理論上說,只需要remove這個zoom view就可以,但是我沒找到擷取該view的辦法,只好remove掉所有的子view。這樣在activity destroy時就不會報WindowLeaked的錯誤了。
    @Override    public void finish() {        ViewGroup view = (ViewGroup) getWindow().getDecorView();        view.removeAllViews();        super.finish();    }


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.