Java Code Examples for android.support.v4.view.ViewCompat

The following examples show how to use android.support.v4.view.ViewCompat. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: CoordinatorLayoutExample   Source File: ReboundHLayout.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
    // 如果在自定义ViewGroup之上还有父View交给我来处理
    getParent().requestDisallowInterceptTouchEvent(true);
    // dx>0 往左滑动 dx<0往右滑动
    boolean hiddenLeft = dx > 0 && getScrollX() < MAX_WIDTH && !ViewCompat
            .canScrollHorizontally(target, -1);
    boolean showLeft = dx < 0 && !ViewCompat.canScrollHorizontally(target, -1);
    boolean hiddenRight = dx < 0 && getScrollX() > MAX_WIDTH && !ViewCompat
            .canScrollHorizontally(target, 1);
    boolean showRight = dx > 0 && !ViewCompat.canScrollHorizontally(target, 1);
    if (hiddenLeft || showLeft || hiddenRight || showRight) {
        scrollBy(dx / mDrag, 0);
        consumed[0] = dx;
    }

    // 限制错位问题
    if (dx > 0 && getScrollX() > MAX_WIDTH && !ViewCompat.canScrollHorizontally(target, -1)) {
        scrollTo(MAX_WIDTH, 0);
    }
    if (dx < 0 && getScrollX() < MAX_WIDTH && !ViewCompat.canScrollHorizontally(target, 1)) {
        scrollTo(MAX_WIDTH, 0);
    }
}
 
Example 2
Source Project: FlycoSystemBar   Source File: SystemBarHelper.java    License: MIT License 6 votes vote down vote up
/**
 * Android4.4以上的状态栏着色
 *
 * @param window         一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
 * @param statusBarColor 状态栏颜色
 * @param alpha          透明栏透明度[0.0-1.0]
 */
public static void tintStatusBar(Window window, @ColorInt int statusBarColor, @FloatRange(from = 0.0, to = 1.0) float alpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    } else {
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup decorView = (ViewGroup) window.getDecorView();
    ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
    View rootView = contentView.getChildAt(0);
    if (rootView != null) {
        ViewCompat.setFitsSystemWindows(rootView, true);
    }

    setStatusBar(decorView, statusBarColor, true);
    setTranslucentView(decorView, alpha);
}
 
Example 3
Source Project: Dota2Helper   Source File: MyDefaultItemAnimator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateMove(final RecyclerView.ViewHolder holder, int fromX, int fromY,
                           int toX, int toY) {
    final View view = holder.itemView;
    fromX += ViewCompat.getTranslationX(holder.itemView);
    fromY += ViewCompat.getTranslationY(holder.itemView);
    resetAnimation(holder);
    int deltaX = toX - fromX;
    int deltaY = toY - fromY;
    if (deltaX == 0 && deltaY == 0) {
        dispatchMoveFinished(holder);
        return false;
    }
    if (deltaX != 0) {
        ViewCompat.setTranslationX(view, -deltaX);
    }
    if (deltaY != 0) {
        ViewCompat.setTranslationY(view, -deltaY);
    }
    mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
    return true;
}
 
Example 4
Source Project: MiBandDecompiled   Source File: SlidingPaneLayout.java    License: Apache License 2.0 6 votes vote down vote up
boolean a(float f1, int i1)
{
    if (!j)
    {
        return false;
    }
    LayoutParams layoutparams = (LayoutParams)k.getLayoutParams();
    int j1 = (int)((float)(getPaddingLeft() + layoutparams.leftMargin) + f1 * (float)n);
    if (t.smoothSlideViewTo(k, j1, k.getTop()))
    {
        a();
        ViewCompat.postInvalidateOnAnimation(this);
        return true;
    } else
    {
        return false;
    }
}
 
Example 5
Source Project: V.FlyoutTest   Source File: DrawerLayout.java    License: MIT License 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

    info.setSource(host);
    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }
    copyNodeInfoNoChildren(info, superNode);

    superNode.recycle();

    addChildrenForAccessibility(info, (ViewGroup) host);
}
 
Example 6
Source Project: letv   Source File: FragmentManagerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@CallSuper
public void onAnimationStart(Animation animation) {
    if (this.mView != null) {
        this.mShouldRunOnHWLayer = FragmentManagerImpl.shouldRunOnHWLayer(this.mView, animation);
        if (this.mShouldRunOnHWLayer) {
            this.mView.post(new Runnable() {
                public void run() {
                    ViewCompat.setLayerType(AnimateOnHWLayerIfNeededListener.this.mView, 2, null);
                }
            });
        }
    }
    if (this.mOrignalListener != null) {
        this.mOrignalListener.onAnimationStart(animation);
    }
}
 
Example 7
Source Project: Dashboard   Source File: DetailActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mImageView = (ImageView) findViewById(R.id.image);
    progressBar = (ProgressBar) findViewById(R.id.loading);
    mAttacher = new PhotoViewAttacher(mImageView);


    ViewCompat.setTransitionName(mImageView, EXTRA_IMAGE);
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(mImageView, new Callback.EmptyCallback() {
        @Override public void onSuccess() {
            progressBar.setVisibility(View.GONE);
        }
        @Override
        public void onError() {
            progressBar.setVisibility(View.GONE);
        }


    });
}
 
Example 8
Source Project: adt-leanback-support   Source File: DefaultItemAnimator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,
        int fromX, int fromY, int toX, int toY) {
    final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
    final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
    final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
    endAnimation(oldHolder);
    int deltaX = (int) (toX - fromX - prevTranslationX);
    int deltaY = (int) (toY - fromY - prevTranslationY);
    // recover prev translation state after ending animation
    ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
    ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
    ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
    if (newHolder != null && newHolder.itemView != null) {
        // carry over translation values
        endAnimation(newHolder);
        ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
        ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
        ViewCompat.setAlpha(newHolder.itemView, 0);
    }
    mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
    return true;
}
 
Example 9
/**
 * Same animation that FloatingActionButton.Behavior
 * uses to show the FAB when the AppBarLayout enters
 *
 * @param floatingActionButton FAB
 */
//
private void animateIn(FloatingActionButton floatingActionButton) {
    if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) {
        return;
    }
    floatingActionButton.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(floatingActionButton).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(), android.R.anim.fade_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        floatingActionButton.startAnimation(anim);
    }
}
 
Example 10
@Override
public void setUpViews() {
	ViewCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.appbar_elevation));

	switch (flag) {
		case FLAG_MAIN:
			mFragment = new SettingsMain();
			break;
		case FLAG_LICENSE:
			mFragment = new SettingsLicense();
			break;
	}
	getFragmentManager().beginTransaction()
			.replace(R.id.container, mFragment)
			.commit();
}
 
Example 11
Source Project: android-sliding-layer-lib   Source File: SlidingLayer.java    License: Apache License 2.0 6 votes vote down vote up
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {

        if (v instanceof ViewGroup) {
            final ViewGroup group = (ViewGroup) v;
            final int scrollX = v.getScrollX();
            final int scrollY = v.getScrollY();

            final int count = group.getChildCount();
            // Count backwards - let topmost views consume scroll distance first.
            for (int i = count - 1; i >= 0; i--) {
                // TODO: Add versioned support here for transformed views.
                // This will not work for transformed views in Honeycomb+
                final View child = group.getChildAt(i);
                if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
                        y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
                        canScroll(child, true, dx, dy, x + scrollX - child.getLeft(),
                                y + scrollY - child.getTop())) {
                    return true;
                }
            }
        }

        return checkV && (
                (allowedDirection() == HORIZONTAL && ViewCompat.canScrollHorizontally(v, -dx) ||
                        allowedDirection() == VERTICAL && ViewCompat.canScrollVertically(v, -dy)));
    }
 
Example 12
Source Project: insets-dispatcher   Source File: InsetView.java    License: Apache License 2.0 6 votes vote down vote up
private void setInsets(Rect insets) {
    if (insets == null || mWindowInset == -1) return;
    final ViewGroup.LayoutParams lp = getLayoutParams();
    switch (mWindowInset) {
        case 0:
            lp.width = insets.left;
            break;
        case 1:
            lp.height = insets.top;
            break;
        case 2:
            lp.width = insets.right;
            break;
        case 3:
            lp.height = insets.bottom;
            break;
    }
    setLayoutParams(lp);
    ViewCompat.postInvalidateOnAnimation(this);
}
 
Example 13
Source Project: Android   Source File: MaterialBadgeTextView.java    License: MIT License 6 votes vote down vote up
/**
 *
 * @param isDisplayInToolbarMenu
 */
public void setHighLightMode(boolean isDisplayInToolbarMenu){
    isHighLightMode = true;
    ViewGroup.LayoutParams params = getLayoutParams();
    params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    params.height = params.width;
    if(isDisplayInToolbarMenu && params instanceof FrameLayout.LayoutParams){
        ((FrameLayout.LayoutParams)params).topMargin=dp2px(getContext(), 10);
        ((FrameLayout.LayoutParams)params).rightMargin=dp2px(getContext(), 10);
    }
    setLayoutParams(params);

    final int diameter = getWidth() - (int) (2.5 * (float) mShadowRadius);
    OvalShadow oval = new OvalShadow(mShadowRadius, diameter);
    ShapeDrawable drawable = new ShapeDrawable(oval);
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, drawable.getPaint());
    drawable.getPaint().setColor(backgroundColor);
    drawable.getPaint().setAntiAlias(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(drawable);
    } else {
        setBackgroundDrawable(drawable);
    }
    setText("");
    setVisibility(View.VISIBLE);
}
 
Example 14
Source Project: fingerpoetry-android   Source File: BoardView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void computeScroll() {
    if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
        int x = mScroller.getCurrX();
        int y = mScroller.getCurrY();
        if (getScrollX() != x || getScrollY() != y) {
            scrollTo(x, y);
        }

        // If auto scrolling at the same time as the scroller is running,
        // then update the drag item position to prevent stuttering item
        if (mAutoScroller.isAutoScrolling()) {
            mDragItem.setPosition(getListTouchX(mCurrentRecyclerView), getListTouchY(mCurrentRecyclerView));
        }

        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        super.computeScroll();
    }
}
 
Example 15
/**
 * Converts a given set of flags to absolution direction which means {@link #START} and
 * {@link #END} are replaced with {@link #LEFT} and {@link #RIGHT} depending on the layout
 * direction.
 *
 * @param flags           The flag value that include any number of movement flags.
 * @param layoutDirection The layout direction of the RecyclerView.
 * @return Updated flags which includes only absolute direction values.
 */
public int convertToAbsoluteDirection(int flags, int layoutDirection) {
    int masked = flags & RELATIVE_DIR_FLAGS;
    if (masked == 0) {
        return flags; // does not have any relative flags, good.
    }
    flags &= ~masked; //remove start / end
    if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) {
        // no change. just OR with 2 bits shifted mask and return
        flags |= masked >> 2; // START is 2 bits after LEFT, END is 2 bits after RIGHT.
        return flags;
    } else {
        // add START flag as RIGHT
        flags |= ((masked >> 1) & ~RELATIVE_DIR_FLAGS);
        // first clean start bit then add END flag as LEFT
        flags |= ((masked >> 1) & RELATIVE_DIR_FLAGS) >> 2;
    }
    return flags;
}
 
Example 16
Source Project: SimpleNews   Source File: BaseItemAnimator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
  final View view = holder.itemView;
  fromX += ViewCompat.getTranslationX(holder.itemView);
  fromY += ViewCompat.getTranslationY(holder.itemView);
  endAnimation(holder);
  int deltaX = toX - fromX;
  int deltaY = toY - fromY;
  if (deltaX == 0 && deltaY == 0) {
    dispatchMoveFinished(holder);
    return false;
  }
  if (deltaX != 0) {
    ViewCompat.setTranslationX(view, -deltaX);
  }
  if (deltaY != 0) {
    ViewCompat.setTranslationY(view, -deltaY);
  }
  mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
  return true;
}
 
Example 17
Source Project: weex-uikit   Source File: WXSwipeLayout.java    License: MIT License 6 votes vote down vote up
/**
 * Whether child view can scroll up
 * @return
 */
public boolean canChildScrollUp() {
  if (mTargetView == null) {
    return false;
  }
  if (Build.VERSION.SDK_INT < 14) {
    if (mTargetView instanceof AbsListView) {
      final AbsListView absListView = (AbsListView) mTargetView;
      return absListView.getChildCount() > 0
             && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                                                                  .getTop() < absListView.getPaddingTop());
    } else {
      return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
    }
  } else {
    return ViewCompat.canScrollVertically(mTargetView, -1);
  }
}
 
Example 18
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
    // if this is a List < L or another view that doesn't support nested
    // scrolling, ignore this request so that the vertical scroll event
    // isn't stolen
    if ((android.os.Build.VERSION.SDK_INT < 21 && mTarget instanceof AbsListView)
            || (mTarget != null && !ViewCompat.isNestedScrollingEnabled(mTarget))) {
        // Nope.
    } else {
        super.requestDisallowInterceptTouchEvent(b);
    }
}
 
Example 19
Source Project: Collection-Android   Source File: FlexboxLayout.java    License: MIT License 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int layoutDirection = ViewCompat.getLayoutDirection(this);
    boolean isRtl;
    switch (mFlexDirection) {
        case FlexDirection.ROW:
            isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
            layoutHorizontal(isRtl, left, top, right, bottom);
            break;
        case FlexDirection.ROW_REVERSE:
            isRtl = layoutDirection != ViewCompat.LAYOUT_DIRECTION_RTL;
            layoutHorizontal(isRtl, left, top, right, bottom);
            break;
        case FlexDirection.COLUMN:
            isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
            if (mFlexWrap == FlexWrap.WRAP_REVERSE) {
                isRtl = !isRtl;
            }
            layoutVertical(isRtl, false, left, top, right, bottom);
            break;
        case FlexDirection.COLUMN_REVERSE:
            isRtl = layoutDirection == ViewCompat.LAYOUT_DIRECTION_RTL;
            if (mFlexWrap == FlexWrap.WRAP_REVERSE) {
                isRtl = !isRtl;
            }
            layoutVertical(isRtl, true, left, top, right, bottom);
            break;
        default:
            throw new IllegalStateException("Invalid flex direction is set: " + mFlexDirection);
    }
}
 
Example 20
Source Project: SlidingUpPaneLayout   Source File: SlidingUpPaneLayout.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (mChildView.getParent() == SlidingUpPaneLayout.this) {
        ViewCompat.setLayerType(mChildView, ViewCompat.LAYER_TYPE_NONE, null);
        invalidateChildRegion(mChildView);
    }
    mPostedRunnables.remove(this);
}
 
Example 21
Source Project: MyBlogDemo   Source File: ViewOffsetHelper.java    License: Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example 22
Source Project: KUtils-master   Source File: ZoomFadePageTransformer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handleRightPage(View view, float position) {
    ViewCompat.setTranslationX(view, -view.getWidth() * position);

    ViewCompat.setPivotX(view, view.getWidth() * 0.5f);
    ViewCompat.setPivotY(view, view.getHeight() * 0.5f);
    ViewCompat.setScaleX(view, 1 - position);
    ViewCompat.setScaleY(view, 1 - position);
    ViewCompat.setAlpha(view, 1 - position);
}
 
Example 23
Source Project: material-drawer   Source File: ScrimInsetsFrameLayout.java    License: MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected boolean fitSystemWindows(Rect insets) {
    mInsets = new Rect(insets);
    setWillNotDraw(mInsetForeground == null);
    ViewCompat.postInvalidateOnAnimation(this);
    if (mOnInsetsCallback != null) {
        mOnInsetsCallback.onInsetsChanged(insets);
    }
    return true; // consume insets
}
 
Example 24
@Override
protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
    ViewCompat.animate(holder.itemView)
            .scaleX(0).scaleY(0)
            .setDuration(getRemoveDuration())
            .setListener(new DefaultRemoveVpaListener(holder))
            .start();
}
 
Example 25
Source Project: SwipeBack   Source File: ViewDragHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Move the captured settling view by the appropriate amount for the current time.
 * If <code>continueSettling</code> returns true, the caller should call it again
 * on the next frame to continue.
 *
 * @param deferCallbacks true if state callbacks should be deferred via posted message.
 *                       Set this to true if you are calling this method from
 *                       {@link android.view.View#computeScroll()} or similar methods
 *                       invoked as part of layout or drawing.
 * @return true if settle is still in progress
 */
public boolean continueSettling(boolean deferCallbacks) {
    if (mDragState == STATE_SETTLING) {
        boolean keepGoing = mScroller.computeScrollOffset();
        final int x = mScroller.getCurrX();
        final int y = mScroller.getCurrY();
        final int dx = x - mCapturedView.getLeft();
        final int dy = y - mCapturedView.getTop();

        if (dx != 0) {
            ViewCompat.offsetLeftAndRight(mCapturedView, dx);
        }
        if (dy != 0) {
            ViewCompat.offsetTopAndBottom(mCapturedView, dy);
        }

        if (dx != 0 || dy != 0) {
            mCallback.onViewPositionChanged(mCapturedView, x, y, dx, dy);
        }

        if (keepGoing && x == mScroller.getFinalX() && y == mScroller.getFinalY()) {
            // Close enough. The interpolator/scroller might think we're still moving
            // but the user sure doesn't.
            mScroller.abortAnimation();
            keepGoing = false;
        }

        if (!keepGoing) {
            if (deferCallbacks) {
                mParentView.post(mSetIdleRunnable);
            } else {
                setDragState(STATE_IDLE);
            }
        }
    }

    return mDragState == STATE_SETTLING;
}
 
Example 26
Source Project: guideshow   Source File: SlidingPaneLayout.java    License: MIT License 5 votes vote down vote up
@Override
public void run() {
    if (mChildView.getParent() == SlidingPaneLayout.this) {
        ViewCompat.setLayerType(mChildView, ViewCompat.LAYER_TYPE_NONE, null);
        invalidateChildRegion(mChildView);
    }
    mPostedRunnables.remove(this);
}
 
Example 27
Source Project: adt-leanback-support   Source File: DrawerLayout.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the title of the drawer with the given gravity.
 *
 * @param edgeGravity Gravity.LEFT, RIGHT, START or END. Expresses which
 *            drawer to return the title for.
 * @return The title of the drawer, or null if none set.
 * @see #setDrawerTitle(int, CharSequence)
 */
@Nullable
public CharSequence getDrawerTitle(@EdgeGravity int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(
            edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.LEFT) {
        return mTitleLeft;
    } else if (absGravity == Gravity.RIGHT) {
        return mTitleRight;
    }
    return null;
}
 
Example 28
Source Project: Music-Player   Source File: InsetsPercentRelativeLayout.java    License: Apache License 2.0 5 votes vote down vote up
public InsetsPercentRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    ViewCompat.setOnApplyWindowInsetsListener(this, new android.support.v4.view.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            setWindowInsets(insets);
            return insets.consumeSystemWindowInsets();
        }
    });
}
 
Example 29
Source Project: NIM_Android_UIKit   Source File: SuperSwipeRefreshLayout.java    License: MIT License 5 votes vote down vote up
private void setAnimationProgress(float progress) {
    if (!usingDefaultHeader) {
        progress = 1;
    }
    ViewCompat.setScaleX(mHeadViewContainer, progress);
    ViewCompat.setScaleY(mHeadViewContainer, progress);
}
 
Example 30
Source Project: ChatKit   Source File: MessageHolders.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public final void applyStyle(MessagesListStyle style) {
    super.applyStyle(style);
    if (time != null) {
        time.setTextColor(style.getOutcomingImageTimeTextColor());
        time.setTextSize(TypedValue.COMPLEX_UNIT_PX, style.getOutcomingImageTimeTextSize());
        time.setTypeface(time.getTypeface(), style.getOutcomingImageTimeTextStyle());
    }

    if (imageOverlay != null) {
        ViewCompat.setBackground(imageOverlay, style.getOutcomingImageOverlayDrawable());
    }
}