Java Code Examples for android.widget.LinearLayout#getHeight()

The following examples show how to use android.widget.LinearLayout#getHeight() . 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 File: BottomBehavior.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) {
    parent.onLayoutChild(child, layoutDirection);
    if (isFirst) {
        isFirst = false;
        if (oLy == 0) {
            oLy = child.getY() + child.getHeight();
        }
        for (int i = 0; i < parent.getChildCount(); i++) {
            View view = parent.getChildAt(i);
            if (view instanceof AppBarLayout) {
                height = view.getMeasuredHeight();
                break;
            }
        }

        child.setY(oLy);
    }

    return true;
}
 
Example 2
Source File: BottomBehavior.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public boolean onLayoutChild(CoordinatorLayout parent, LinearLayout child, int layoutDirection) {
    parent.onLayoutChild(child, layoutDirection);
    if (isFirst) {
        isFirst = false;
        if (oLy == 0) {
            oLy = child.getY() + child.getHeight();
        }
        for (int i = 0; i < parent.getChildCount(); i++) {
            View view = parent.getChildAt(i);
            if (view instanceof AppBarLayout) {
                height = view.getMeasuredHeight();
                break;
            }
        }

        child.setY(oLy);
    }

    return true;
}
 
Example 3
Source File: WebRichActivity.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
/**
 * 关闭动画
 *
 * @param view 关闭动画的view
 */
private void animateClose(final LinearLayout view) {
    int origHeight = view.getHeight();
    ValueAnimator animator = createDropAnimator(view, origHeight, 0);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
            isAnimating = false;
        }
    });
    animator.start();
}
 
Example 4
Source File: ChangeTabLayout.java    From ChangeTabLayout with Apache License 2.0 4 votes vote down vote up
private void scrollToTab(int tabIndex, float positionOffset) {

        final int tabStripChildCount = tabStrip.getChildCount();
        if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
            return;
        }

        LinearLayout selectedTab = (LinearLayout) getTabAt(tabIndex);

        if (0f <= positionOffset && positionOffset < 1f) {
            if(!tabLayoutState){
                ImageView imageView = (ImageView) selectedTab.getChildAt(0);
                ((RevealDrawable)imageView.getDrawable()).setOrientation(RevealDrawable.VERTICAL);
                imageView.setImageLevel((int) (positionOffset * 5000 + 5000));
            }
            if(flag){
                ChangeTextView textView = (ChangeTextView) selectedTab.getChildAt(1);
                textView.setLevel((int) (positionOffset * 5000 + 5000));
            }
        }

        if(!(tabIndex + 1 >= tabStripChildCount)){
            LinearLayout tab = (LinearLayout) getTabAt(tabIndex + 1);

            if(!tabLayoutState){
                ImageView img = (ImageView) tab.getChildAt(0);
                ((RevealDrawable)img.getDrawable()).setOrientation(RevealDrawable.VERTICAL);
                img.setImageLevel((int) (positionOffset * 5000));
            }
            if(flag){
                ChangeTextView text = (ChangeTextView) tab.getChildAt(1);
                text.setLevel((int) (positionOffset * 5000));
            }
        }

        int titleOffset = tabViewHeight * 2;
        int extraOffset = (int) (positionOffset * selectedTab.getHeight());

        int y = (tabIndex > 0 || positionOffset > 0) ? -titleOffset : 0;
        int start = selectedTab.getTop();
        y += start + extraOffset;

        scrollTo(0, y);
    }