本文整理汇总了Java中android.view.ViewTreeObserver.OnPreDrawListener方法的典型用法代码示例。如果您正苦于以下问题:Java ViewTreeObserver.OnPreDrawListener方法的具体用法?Java ViewTreeObserver.OnPreDrawListener怎么用?Java ViewTreeObserver.OnPreDrawListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewTreeObserver
的用法示例。
在下文中一共展示了ViewTreeObserver.OnPreDrawListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import android.view.ViewTreeObserver; //导入方法依赖的package包/类
@Override
protected void execute(@NonNull final ViewGroup container, @NonNull final SceneInfo upper,
@NonNull final List<SceneInfo> lower, @NonNull final OnCompleteListener listener) {
this.listener = listener;
view = getFirstNonLaidOutView(upper, lower);
if (view != null) {
onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
if (view != null && onPreDrawListener != null) {
view.getViewTreeObserver().removeOnPreDrawListener(onPreDrawListener);
}
view = null;
onPreDrawListener = null;
animate(container, upper, lower);
return true;
}
};
view.getViewTreeObserver().addOnPreDrawListener(onPreDrawListener);
} else {
animate(container, upper, lower);
}
}
示例2: addPreDrawListener
import android.view.ViewTreeObserver; //导入方法依赖的package包/类
void addPreDrawListener() {
if (mPreDrawListener != null) {
return;
}
mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
final boolean titleOnTwoLines = (mTitle.getLineCount() > 1);
int bodymaxLines = titleOnTwoLines ? 3 : 5; // MAGICAL
if (mBody.getMaxLines() != bodymaxLines) {
mBody.setMaxLines(bodymaxLines);
return false;
} else {
removePreDrawListener();
return true;
}
}
};
view.getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
}
示例3: addPreDrawListener
import android.view.ViewTreeObserver; //导入方法依赖的package包/类
void addPreDrawListener() {
if (mPreDrawListener != null) {
return;
}
mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
final boolean titleOnTwoLines = (mTitle.getLineCount() > 1);
final boolean hasEpisodeLine = (mEpisodeGroup.getVisibility()==View.VISIBLE);
int bodymaxLines = titleOnTwoLines ? 3 : 5; // MAGICAL
if (hasEpisodeLine) bodymaxLines-=1; // MAGICAL
if (mBody.getMaxLines() != bodymaxLines) {
mBody.setMaxLines(bodymaxLines);
return false;
} else {
removePreDrawListener();
return true;
}
}
};
view.getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
}
示例4: setXFraction
import android.view.ViewTreeObserver; //导入方法依赖的package包/类
/**
* Set the X translation as a fraction of the width of this view. Make sure this method is not
* stripped out by proguard when using this with {@link android.animation.ObjectAnimator}. You
* may need to add
* <code>
* -keep @com.android.setupwizardlib.annotations.Keep class *
* </code>
* to your proguard configuration if you are seeing mysterious {@link NoSuchMethodError} at
* runtime.
*/
@Keep
@TargetApi(VERSION_CODES.HONEYCOMB)
public void setXFraction(float fraction) {
mXFraction = fraction;
final int width = getWidth();
if (width != 0) {
setTranslationX(width * fraction);
} else {
// If we haven't done a layout pass yet, wait for one and then set the fraction before
// the draw occurs using an OnPreDrawListener. Don't call translationX until we know
// getWidth() has a reliable, non-zero value or else we will see the fragment flicker on
// screen.
if (mPreDrawListener == null) {
mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(mPreDrawListener);
setXFraction(mXFraction);
return true;
}
};
getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
}
}
}
示例5: runJustBeforeBeingDrawn
import android.view.ViewTreeObserver; //导入方法依赖的package包/类
/**
* Runs the code just before the given view is being drawn so that its size has been already
* calculated.
*
* @param view View to be drawn.
* @param runnable Code to run.
*/
private static void runJustBeforeBeingDrawn(final View view, final Runnable runnable) {
final ViewTreeObserver.OnPreDrawListener onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
view.getViewTreeObserver().removeOnPreDrawListener(this);
runnable.run();
return true;
}
};
view.getViewTreeObserver().addOnPreDrawListener(onPreDrawListener);
}
示例6: ensurePreDrawListener
import android.view.ViewTreeObserver; //导入方法依赖的package包/类
private void ensurePreDrawListener() {
if (mPreDrawListener == null) {
mPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
FloatingActionButtonImpl.this.onPreDraw();
return true;
}
};
}
}