当前位置: 首页>>代码示例>>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;未经允许,请勿转载。