本文整理匯總了Java中android.view.ViewParent.getChildVisibleRect方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewParent.getChildVisibleRect方法的具體用法?Java ViewParent.getChildVisibleRect怎麽用?Java ViewParent.getChildVisibleRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.ViewParent
的用法示例。
在下文中一共展示了ViewParent.getChildVisibleRect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPreDraw
import android.view.ViewParent; //導入方法依賴的package包/類
@Override
public boolean onPreDraw() {
ViewParent parent = mView.getParent();
if (parent != null) {
Rect rect = new Rect(0, 0, mView.getWidth(), mView.getHeight());
// Track impression if at least 2/3 of the view is visible.
// |getChildVisibleRect| returns false when the view is empty, which may happen when
// dismissing or reassigning a View. In this case |rect| appears to be invalid.
if (parent.getChildVisibleRect(mView, rect, null)
&& rect.height() >= 2 * mView.getHeight() / 3) {
mTriggered = true;
mListener.onImpression();
}
}
// Proceed with the current drawing pass.
return true;
}