本文整理匯總了Java中android.support.v4.view.ViewCompat.isLaidOut方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewCompat.isLaidOut方法的具體用法?Java ViewCompat.isLaidOut怎麽用?Java ViewCompat.isLaidOut使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.view.ViewCompat
的用法示例。
在下文中一共展示了ViewCompat.isLaidOut方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showFab
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public static void showFab(@Nullable FloatingActionButton fab)
{
if (fab == null)
return;
if (ViewCompat.isLaidOut(fab))
{
fab.show();
return;
}
fab.animate().cancel();
fab.setScaleX(0f);
fab.setScaleY(0f);
fab.setAlpha(0f);
fab.setVisibility(View.VISIBLE);
fab.animate().setDuration(200).scaleX(1).scaleY(1).alpha(1).setInterpolator(new LinearOutSlowInInterpolator());
}
示例2: hideFab
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public static void hideFab(@Nullable FloatingActionButton fab)
{
if (fab == null)
return;
if (ViewCompat.isLaidOut(fab))
{
fab.hide();
return;
}
fab.animate().cancel();
fab.setScaleX(1f);
fab.setScaleY(1f);
fab.setAlpha(1f);
fab.setVisibility(View.GONE);
fab.animate().setDuration(200).scaleX(0).scaleY(0).alpha(0).setInterpolator(new LinearOutSlowInInterpolator());
}
示例3: animateToTab
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void animateToTab(int newPosition) {
if (newPosition == Tab.INVALID_POSITION) {
return;
}
if (getWindowToken() == null || !ViewCompat.isLaidOut(this)
|| mTabStrip.childrenNeedLayout()) {
// If we don't have a window token, or we haven't been laid out yet just draw the new
// position now
setScrollPosition(newPosition, 0f, true);
return;
}
final int startScrollX = getScrollX();
final int targetScrollX = calculateScrollXForTab(newPosition, 0);
if (startScrollX != targetScrollX) {
ensureScrollAnimator();
mScrollAnimator.setIntValues(startScrollX, targetScrollX);
mScrollAnimator.start();
}
// Now animate the indicator
mTabStrip.animateIndicatorToPosition(newPosition, ANIMATION_DURATION);
}
示例4: animateShowSwitcher
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
* Shows the tab switcher in an animated manner.
*
* @param referenceTabIndex
* The index of the tab, which is used as a reference, when restoring the positions of
* tabs, as an {@link Integer} value or -1, if the positions of tabs should not be
* restored
* @param referenceTabPosition
* The position of tab, which is used as a reference, when restoring the positions of
* tabs, in relation to the available space as a {@link Float} value or -1, if the
* positions of tabs should not be restored
*/
private void animateShowSwitcher(final int referenceTabIndex,
final float referenceTabPosition) {
AbstractItem[] items = calculateInitialItems(referenceTabIndex, referenceTabPosition);
AbstractItemIterator iterator = new InitialItemIteratorBuilder(items).create();
AbstractItem item;
while ((item = iterator.next()) != null) {
if (((TabItem) item).getTab() == getModel().getSelectedTab() || item.isVisible()) {
tabViewRecycler.inflate(item);
View view = item.getView();
if (!ViewCompat.isLaidOut(view)) {
view.getViewTreeObserver().addOnGlobalLayoutListener(
new LayoutListenerWrapper(view,
createShowSwitcherLayoutListener(item)));
} else {
animateShowSwitcher(item, createUpdateViewAnimationListener(item));
}
}
}
animateToolbarVisibility(getModel().areToolbarsShown(), toolbarVisibilityAnimationDelay);
}
示例5: onDraw
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (!mIsHintSet && ViewCompat.isLaidOut(this)) {
// We have to reset the previous hint so that equals check pass
setHint(null);
// In case that hint is changed programatically
CharSequence currentEditTextHint = getEditText().getHint();
if (currentEditTextHint != null && currentEditTextHint.length() > 0) {
mHint = currentEditTextHint;
}
setHint(mHint);
mIsHintSet = true;
}
}
示例6: performChange
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@Override
public final void performChange(@NonNull final ViewGroup container, @Nullable final View from, @Nullable final View to, final boolean isPush, @NonNull final ControllerChangeCompletedListener changeListener) {
if (to != null && !ViewCompat.isLaidOut(to)) {
to.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
final ViewTreeObserver observer = to.getViewTreeObserver();
if (observer.isAlive()) {
observer.removeOnPreDrawListener(this);
}
performAnimation(container, from, to, isPush, changeListener);
return true;
}
});
} else {
performAnimation(container, from, to, isPush, changeListener);
}
}
示例7: onMeasureChild
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public boolean onMeasureChild(CoordinatorLayout parent, View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
int childLpHeight = child.getLayoutParams().height;
if (childLpHeight == -1 || childLpHeight == -2) {
View header = findFirstDependency(parent.getDependencies(child));
if (header != null) {
if (ViewCompat.getFitsSystemWindows(header) && !ViewCompat.getFitsSystemWindows(child)) {
ViewCompat.setFitsSystemWindows(child, true);
if (ViewCompat.getFitsSystemWindows(child)) {
child.requestLayout();
return true;
}
}
if (ViewCompat.isLaidOut(header)) {
int availableHeight = MeasureSpec.getSize(parentHeightMeasureSpec);
if (availableHeight == 0) {
availableHeight = parent.getHeight();
}
parent.onMeasureChild(child, parentWidthMeasureSpec, widthUsed, MeasureSpec.makeMeasureSpec((availableHeight - header.getMeasuredHeight()) + getScrollRange(header), childLpHeight == -1 ? 1073741824 : Integer.MIN_VALUE), heightUsed);
return true;
}
}
}
return false;
}
示例8: animateToTab
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void animateToTab(int newPosition) {
if (newPosition != -1) {
if (getWindowToken() == null || !ViewCompat.isLaidOut(this) || this.mTabStrip.childrenNeedLayout()) {
setScrollPosition(newPosition, 0.0f, true);
return;
}
int startScrollX = getScrollX();
int targetScrollX = calculateScrollXForTab(newPosition, 0.0f);
if (startScrollX != targetScrollX) {
if (this.mScrollAnimator == null) {
this.mScrollAnimator = ViewUtils.createAnimator();
this.mScrollAnimator.setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
this.mScrollAnimator.setDuration(300);
this.mScrollAnimator.setUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimatorCompat animator) {
TabLayout.this.scrollTo(animator.getAnimatedIntValue(), 0);
}
});
}
this.mScrollAnimator.setIntValues(startScrollX, targetScrollX);
this.mScrollAnimator.start();
}
this.mTabStrip.animateIndicatorToPosition(newPosition, 300);
}
}
示例9: animateShowSwitcher
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
* Shows the tab switcher in an animated manner.
*/
private void animateShowSwitcher() {
TabItem[] tabItems = calculateInitialTabItems(-1, -1);
AbstractTabItemIterator iterator = new InitialTabItemIterator(tabItems, false, 0);
TabItem tabItem;
while ((tabItem = iterator.next()) != null) {
if (tabItem.getTab() == getModel().getSelectedTab() || tabItem.isVisible()) {
viewRecycler.inflate(tabItem);
View view = tabItem.getView();
if (!ViewCompat.isLaidOut(view)) {
view.getViewTreeObserver().addOnGlobalLayoutListener(
new LayoutListenerWrapper(view,
createShowSwitcherLayoutListener(tabItem)));
} else {
animateShowSwitcher(tabItem, createUpdateViewAnimationListener(tabItem));
}
}
}
animateToolbarVisibility(getModel().areToolbarsShown(), toolbarVisibilityAnimationDelay);
}
示例10: shouldAnimateVisibilityChange
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private boolean shouldAnimateVisibilityChange() {
View label = getLabelView();
if (label != null) {
return ViewCompat.isLaidOut(this) && ViewCompat.isLaidOut(label) && !isInEditMode();
} else {
return ViewCompat.isLaidOut(this) && !isInEditMode();
}
}
示例11: animateToTab
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
private void animateToTab(int newPosition) {
clearAnimation();
if (newPosition == Tab.INVALID_POSITION) {
return;
}
if (getWindowToken() == null || !ViewCompat.isLaidOut(this)) {
// If we don't have a window token, or we haven't been laid out yet just draw the new
// position now
setScrollPosition(newPosition, 0f);
return;
}
final int startScrollX = getScrollX();
final int targetScrollX = calculateScrollXForTab(newPosition, 0);
final int duration = ANIMATION_DURATION;
if (startScrollX != targetScrollX) {
final Animation animation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final float value = lerp(startScrollX, targetScrollX, interpolatedTime);
scrollTo((int) value, 0);
}
};
animation.setInterpolator(INTERPOLATOR);
animation.setDuration(duration);
startAnimation(animation);
}
// Now animate the indicator
mTabStrip.animateIndicatorToPosition(newPosition, duration);
}
示例12: getContentRect
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
/**
* Return in {@code rect} the bounds of the actual floating action button content in view-local
* coordinates. This is defined as anything within any visible shadow.
*
* @return true if this view actually has been laid out and has a content rect, else false.
*/
public boolean getContentRect(@NonNull Rect rect) {
if (ViewCompat.isLaidOut(this)) {
rect.set(0, 0, getWidth(), getHeight());
rect.left += mShadowPadding.left;
rect.top += mShadowPadding.top;
rect.right -= mShadowPadding.right;
rect.bottom -= mShadowPadding.bottom;
return true;
} else {
return false;
}
}
示例13: mimicFabVisibility
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
@UiThread public static void mimicFabVisibility(boolean show, @NonNull View view,
@Nullable FloatingActionButton.OnVisibilityChangedListener listener) {
if (show) {
view.animate().cancel();
if (ViewCompat.isLaidOut(view)) {
if (view.getVisibility() != View.VISIBLE) {
view.setAlpha(0f);
view.setScaleY(0f);
view.setScaleX(0f);
}
view.animate()
.scaleX(1f)
.scaleY(1f)
.alpha(1f)
.setDuration(200)
.setInterpolator(LINEAR_OUT_SLOW_IN_INTERPOLATOR)
.withStartAction(() -> {
view.setVisibility(View.VISIBLE);
if (listener != null) listener.onShown(null);
});
} else {
view.setVisibility(View.VISIBLE);
view.setAlpha(1f);
view.setScaleY(1f);
view.setScaleX(1f);
if (listener != null) listener.onShown(null);
}
} else {
view.animate()
.scaleX(0f)
.scaleY(0f)
.alpha(0f)
.setDuration(40)
.setInterpolator(FAST_OUT_LINEAR_IN_INTERPOLATOR);
view.setVisibility(View.GONE);
if (listener != null) listener.onHidden(null);
}
}
示例14: setChecked
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public void setChecked(boolean checked) {
super.setChecked(checked);
checked = isChecked();
if (getWindowToken() != null && ViewCompat.isLaidOut(this) && isShown()) {
animateThumbToCheckedState(checked);
return;
}
cancelPositionAnimator();
setThumbPosition(checked ? 1.0f : 0.0f);
}
示例15: getContentRect
import android.support.v4.view.ViewCompat; //導入方法依賴的package包/類
public boolean getContentRect(@NonNull Rect rect) {
if (!ViewCompat.isLaidOut(this)) {
return false;
}
rect.set(0, 0, getWidth(), getHeight());
rect.left += this.mShadowPadding.left;
rect.top += this.mShadowPadding.top;
rect.right -= this.mShadowPadding.right;
rect.bottom -= this.mShadowPadding.bottom;
return true;
}