當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewTreeObserver.addOnDrawListener方法代碼示例

本文整理匯總了Java中android.view.ViewTreeObserver.addOnDrawListener方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewTreeObserver.addOnDrawListener方法的具體用法?Java ViewTreeObserver.addOnDrawListener怎麽用?Java ViewTreeObserver.addOnDrawListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ViewTreeObserver的用法示例。


在下文中一共展示了ViewTreeObserver.addOnDrawListener方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.view.ViewTreeObserver; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view);

    view = (CustomView) findViewById(R.id.view);

    ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
    viewTreeObserver.addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
        @Override
        public void onDraw() {

        }
    });

    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {

        }
    });
}
 
開發者ID:guoxiaoxing,項目名稱:android-open-source-project-analysis,代碼行數:23,代碼來源:ViewActivity.java

示例2: onWindowVisibilityChanged

import android.view.ViewTreeObserver; //導入方法依賴的package包/類
public void onWindowVisibilityChanged(int visibility) {
    // The following code used to be in onResume, but it turns out onResume is called when
    // you're in All Apps and click home to go to the workspace. onWindowVisibilityChanged
    // is a more appropriate event to handle
    if (visibility == View.VISIBLE) {
        if (!mWorkspaceLoading) {
            final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
            // We want to let Launcher draw itself at least once before we force it to build
            // layers on all the workspace pages, so that transitioning to Launcher from other
            // apps is nice and speedy.
            observer.addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
                private boolean mStarted = false;
                public void onDraw() {
                    if (mStarted) return;
                    mStarted = true;
                    // We delay the layer building a bit in order to give
                    // other message processing a time to run.  In particular
                    // this avoids a delay in hiding the IME if it was
                    // currently shown, because doing that may involve
                    // some communication back with the app.
                    mWorkspace.postDelayed(mBuildLayersRunnable, 500);
                    final ViewTreeObserver.OnDrawListener listener = this;
                    mWorkspace.post(new Runnable() {
                        public void run() {
                            if (mWorkspace != null &&
                                    mWorkspace.getViewTreeObserver() != null) {
                                mWorkspace.getViewTreeObserver().
                                        removeOnDrawListener(listener);
                            }
                        }
                    });
                    return;
                }
            });
        }
        clearTypedText();
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:39,代碼來源:Launcher.java

示例3: onWindowVisibilityChanged

import android.view.ViewTreeObserver; //導入方法依賴的package包/類
public void onWindowVisibilityChanged(int visibility) {
    mVisible = visibility == View.VISIBLE;
    updateAutoAdvanceState();
    // The following code used to be in onResume, but it turns out onResume is called when
    // you're in All Apps and click home to go to the workspace. onWindowVisibilityChanged
    // is a more appropriate event to handle
    if (mVisible) {
        if (!mWorkspaceLoading) {
            final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
            // We want to let Launcher draw itself at least once before we force it to build
            // layers on all the workspace pages, so that transitioning to Launcher from other
            // apps is nice and speedy.
            observer.addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
                private boolean mStarted = false;
                public void onDraw() {
                    if (mStarted) return;
                    mStarted = true;
                    // We delay the layer building a bit in order to give
                    // other message processing a time to run.  In particular
                    // this avoids a delay in hiding the IME if it was
                    // currently shown, because doing that may involve
                    // some communication back with the app.
                    mWorkspace.postDelayed(mBuildLayersRunnable, 500);
                    final ViewTreeObserver.OnDrawListener listener = this;
                    mWorkspace.post(new Runnable() {
                        public void run() {
                            if (mWorkspace != null &&
                                    mWorkspace.getViewTreeObserver() != null) {
                                mWorkspace.getViewTreeObserver().
                                        removeOnDrawListener(listener);
                            }
                        }
                    });
                    return;
                }
            });
        }
        clearTypedText();
    }
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:41,代碼來源:Launcher.java


注:本文中的android.view.ViewTreeObserver.addOnDrawListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。