本文整理匯總了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;
}
};
}
}