當前位置: 首頁>>代碼示例>>Java>>正文


Java View.getHeight方法代碼示例

本文整理匯總了Java中android.view.View.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java View.getHeight方法的具體用法?Java View.getHeight怎麽用?Java View.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.getHeight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: captureView

import android.view.View; //導入方法依賴的package包/類
private Bitmap captureView (View view) {
    int w = view.getWidth();
    int h = view.getHeight();
    if (w <= 0 || h <= 0) {
        throw new RuntimeException("Impossible to snapshot the view: view is invalid");
    }

    Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Bitmap childBitmapBuffer;
    Canvas c = new Canvas(bitmap);
    view.draw(c);
    List<View> childrenList = getAllChildren(view);
    for (View child : childrenList) {
        if(child instanceof TextureView) {
            ((TextureView) child).setOpaque(false);
            childBitmapBuffer = ((TextureView) child).getBitmap(child.getWidth(), child.getHeight());
            c.drawBitmap(childBitmapBuffer, child.getLeft() + ((ViewGroup)child.getParent()).getLeft() +  child.getPaddingLeft(), child.getTop() + ((ViewGroup)child.getParent()).getTop() + child.getPaddingTop(), null);
        }
    }
    if (bitmap == null) {
        throw new RuntimeException("Impossible to snapshot the view");
    }
    return bitmap;
}
 
開發者ID:gre,項目名稱:react-native-webgl-view-shot,代碼行數:25,代碼來源:RNWebGLTextureView.java

示例2: isShouldHideKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 * 根據EditText所在坐標和用戶點擊的坐標相對比,來判斷是否隱藏鍵盤,因為當用戶點擊EditText時則不能隱藏
 *
 * @param v
 * @param event
 * @return
 */
private boolean isShouldHideKeyboard(View v, MotionEvent event) {
    if (v != null && (v instanceof EditText)) {
        int[] l = {0, 0};
        v.getLocationInWindow(l);
        int left = l[0],
                top = l[1],
                bottom = top + v.getHeight(),
                right = left + v.getWidth();
        if (event.getX() > left && event.getX() < right && event.getY() > top && event.getY() < bottom) {
            // 點擊EditText的事件,忽略它。
            return false;
        } else {
            return true;
        }
    }
    // 如果焦點不是EditText則忽略,這個發生在視圖剛繪製完,第一個焦點不在EditText上,和用戶用軌跡球選擇其他的焦點
    return false;
}
 
開發者ID:wangzhaosheng,項目名稱:publicProject,代碼行數:26,代碼來源:BaseActivtiy.java

示例3: onLayout

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    View rootView = getRootView();
    int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
    getWindowVisibleDisplayFrame(rect);
    keyboardHeight = usableViewHeight - (rect.bottom - rect.top);

    if (UserConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) {
        int t = 0;
        if (passwordFrameLayout.getTag() != null) {
            t = (Integer) passwordFrameLayout.getTag();
        }
        LayoutParams layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
        layoutParams.topMargin = t + layoutParams.height - keyboardHeight / 2 - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
        passwordFrameLayout.setLayoutParams(layoutParams);
    }

    super.onLayout(changed, left, top, right, bottom);
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:20,代碼來源:PasscodeView.java

示例4: isShouldHideKeyboard

import android.view.View; //導入方法依賴的package包/類
/**
 * 根據EditText所在坐標和用戶點擊的坐標相對比,來判斷是否隱藏鍵盤,因為當用戶點擊EditText時則不能隱藏
 *
 * @param v
 * @param event
 * @return
 */
private boolean isShouldHideKeyboard(View v, MotionEvent event) {
    if (v != null && (v instanceof EditText)) {
        int[] l = {0, 0};
        v.getLocationInWindow(l);
        int left = l[0],
                top = l[1],
                bottom = top + v.getHeight(),
                right = left + v.getWidth();
        if (event.getX() > left && event.getX() < right
                && event.getY() > top && event.getY() < bottom) {
            // 點擊EditText的事件,忽略它。
            return false;
        } else {
            return true;
        }
    }
    // 如果焦點不是EditText則忽略,這個發生在視圖剛繪製完,第一個焦點不在EditText上,和用戶用軌跡球選擇其他的焦點
    return false;
}
 
開發者ID:wangzhaosheng,項目名稱:publicProject,代碼行數:27,代碼來源:BaseTitleActivity.java

示例5: getFabTranslationYForBottomNavigationBar

import android.view.View; //導入方法依賴的package包/類
private float[] getFabTranslationYForBottomNavigationBar(CoordinatorLayout parent,
                                                         FloatingActionButton fab) {
    float minOffset = 0;
    float viewHeight = 0;
    final List<View> dependencies = parent.getDependencies(fab);
    for (int i = 0, z = dependencies.size(); i < z; i++) {
        final View view = dependencies.get(i);
        if (view instanceof BottomNavigationBar) {
            viewHeight = view.getHeight();
            minOffset = Math.min(minOffset,
                    ViewCompat.getTranslationY(view) - viewHeight);
        }
    }
    float[] returnValues = {minOffset, viewHeight};

    return returnValues;
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:18,代碼來源:BottomNavBarFabBehaviour.java

示例6: viewIdHitPosition

import android.view.View; //導入方法依賴的package包/類
public int viewIdHitPosition(MotionEvent ev, int id) {
    final int x = (int) ev.getX();
    final int y = (int) ev.getY();

    int touchPos = mDslv.pointToPosition(x, y); // includes headers/footers

    final int numHeaders = mDslv.getHeaderViewsCount();
    final int numFooters = mDslv.getFooterViewsCount();
    final int count = mDslv.getCount();

    // Log.d("mobeta", "touch down on position " + itemnum);
    // We're only interested if the touch was on an
    // item that's not a header or footer.
    if (touchPos != AdapterView.INVALID_POSITION && touchPos >= numHeaders
            && touchPos < (count - numFooters)) {
        final View item = mDslv.getChildAt(touchPos - mDslv.getFirstVisiblePosition());
        final int rawX = (int) ev.getRawX();
        final int rawY = (int) ev.getRawY();

        View dragBox = id == 0 ? item : (View) item.findViewById(id);
        if (dragBox != null) {
            dragBox.getLocationOnScreen(mTempLoc);

            if (rawX > mTempLoc[0] && rawY > mTempLoc[1] &&
                    rawX < mTempLoc[0] + dragBox.getWidth() &&
                    rawY < mTempLoc[1] + dragBox.getHeight()) {

                mItemX = item.getLeft();
                mItemY = item.getTop();

                return touchPos;
            }
        }
    }

    return MISS;
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:38,代碼來源:DragSortController.java

示例7: dismiss

import android.view.View; //導入方法依賴的package包/類
/**
 * Unselected choice state in item
 */
protected int dismiss(int position) {
    int start = swipeListView.getFirstVisiblePosition();
    int end = swipeListView.getLastVisiblePosition();
    View view = swipeListView.getChildAt(position - start);
    ++dismissAnimationRefCount;
    if (position >= start && position <= end) {
        performDismiss(view, position, false);
        return view.getHeight();
    } else {
        pendingDismisses.add(new PendingDismissData(position, null));
        return 0;
    }
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:17,代碼來源:SwipeListViewTouchListener.java

示例8: getCalculatedValueY

import android.view.View; //導入方法依賴的package包/類
@Override
public Float getCalculatedValueY(View viewToMove) {
    if (vertical) {
        final int centerYView1 = (int) (view1.getTop() + view1.getHeight() / 2f);
        final int centerYView2 = (int) (view2.getTop() + view2.getHeight() / 2f);

        return (centerYView1 + centerYView2) / 2f - viewToMove.getHeight() / 2f;
    }
    return null;
}
 
開發者ID:florent37,項目名稱:ExpectAnim,代碼行數:11,代碼來源:PositionAnimExpectationCenterBetweenViews.java

示例9: computeRatio

import android.view.View; //導入方法依賴的package包/類
private float computeRatio(RecyclerView recyclerView) {
    final View child0 = recyclerView.getChildAt(0);
    final int pos = recyclerView.getChildAdapterPosition(child0);
    if (pos != 0) {
        return 0;
    }

    final int height = child0.getHeight();
    final float y = Math.max(0, child0.getY());
    return y / height;
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:12,代碼來源:OuterItem.java

示例10: standUp

import android.view.View; //導入方法依賴的package包/類
public AnimationBuilder standUp() {
    for (View view : this.views) {
        float x = (float) ((((view.getWidth() - view.getPaddingLeft()) - view.getPaddingRight
                ()) / 2) + view.getPaddingLeft());
        float y = (float) (view.getHeight() - view.getPaddingBottom());
        pivotX(x, x, x, x, x);
        pivotY(y, y, y, y, y);
        rotationX(55.0f, -30.0f, 15.0f, -15.0f, 0.0f);
    }
    return this;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:AnimationBuilder.java

示例11: onDraw

import android.view.View; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (mOpenChangeDisappearAnimation && mChangeDisappearAnimator != null &&
            mChangeDisappearAnimator.isStarted() && mDetachViewsMap.size() > 0 && mIsAnimating) {
        for (int i = 0; i < mDetachViewsMap.size(); i++) {
            long id = mDetachViewsMap.keyAt(i);
            View view = mDetachViewsMap.valueAt(i);
            int newPos = getPositionForId(id);
            int top, offset = (int) (mChangeDisappearPlayTime / mOffsetDurationUnit);
            if (newPos < getFirstVisiblePosition()) {
                top = mTopMap.get(id) - offset;
                if (top < -view.getHeight()) {
                    continue;
                }
            } else {
                top = mTopMap.get(id) + offset;
                if (top > getHeight()) {
                    continue;
                }
            }
            view.layout(0, top, view.getWidth(), top + view.getHeight());
            view.setAlpha(1f - mChangeDisappearPlayTime * 1f / getChangeDisappearDuration());
            // 不能直接調用view.draw(canvas), 在listview上由於緩存會衝突
            drawChild(canvas, view, getDrawingTime());
        }
    }
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:29,代碼來源:QMUIAnimationListView.java

示例12: isShouldHideInput

import android.view.View; //導入方法依賴的package包/類
/**
 * 根據EditText所在坐標和用戶點擊的坐標相對比,來判斷是否隱藏鍵盤,因為當用戶點擊EditText時沒必要隱藏
 *
 * @param v
 * @param event
 * @return
 */
public static boolean isShouldHideInput(View v, MotionEvent event) {
    if (v != null && (v instanceof EditText)) {
        int[] l = {0, 0};
        v.getLocationInWindow(l);
        int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left
                + v.getWidth();
        return !(event.getX() > left && event.getX() < right
                && event.getY() > top && event.getY() < bottom);
    }
    // 如果焦點不是EditText則忽略,這個發生在視圖剛繪製完,第一個焦點不在EditView上,和用戶用軌跡球選擇其他的焦點  
    return false;
}
 
開發者ID:zhou-you,項目名稱:RxEasyHttp,代碼行數:20,代碼來源:AppTools.java

示例13: optimizeMaxSizeByView

import android.view.View; //導入方法依賴的package包/類
/**
 * @param view				圖形類控件
 * @param maxImageWidth		圖片寬
 * @param maxImageHeight	圖片高
 * @return	如果maxImageWidth和maxImageWidth大於0,此BitmapSize已配置,直接返回。
 * 			否則,根據所傳控件設置BitmapSize,並返回該對象
 * 
 */
public static BitmapSize optimizeMaxSizeByView(View view, int maxImageWidth, int maxImageHeight) {
    int width = maxImageWidth;
    int height = maxImageHeight;

    if (width > 0 && height > 0) {
        return new BitmapSize(width, height);
    }

    final ViewGroup.LayoutParams params = view.getLayoutParams();
    if (params != null) {
        if (params.width > 0) {
            width = params.width;
        } else if (params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
            width = view.getWidth();
        }

        if (params.height > 0) {
            height = params.height;
        } else if (params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
            height = view.getHeight();
        }
    }

    if (width <= 0) width = getFieldValue(view, "mMaxWidth");
    if (height <= 0) height = getFieldValue(view, "mMaxHeight");

    BitmapSize screenSize = getScreenSize(view.getContext());
    if (width <= 0) width = screenSize.getWidth();
    if (height <= 0) height = screenSize.getHeight();

    return new BitmapSize(width, height);
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:41,代碼來源:BitmapCommonUtils.java

示例14: transformPage

import android.view.View; //導入方法依賴的package包/類
public void transformPage(View view, float position, boolean horizontal) {
    int pageSize = horizontal ? view.getWidth() : view.getHeight();
    if (position < -1) { // [-Infinity,-1)way off-screen to the left
        view.setAlpha(MIN_ALPHA);
        view.setScaleX(MIN_SCALE);
        view.setScaleY(MIN_SCALE);
    } else if (position <= 1) { // [-1,1]
        float percent = 1 - Math.abs(position);
        float scale = MIN_SCALE + (1 - MIN_SCALE) * percent;
        if (mAdjustTranslate) {
            float horizontalMargin = pageSize * (1 - scale) / 2;
            if (position > 0) {
                if (horizontal) {
                    view.setTranslationX(horizontalMargin);
                } else {
                    view.setTranslationY(horizontalMargin);
                }
            } else {
                if (horizontal) {
                    view.setTranslationX(-horizontalMargin);
                } else {
                    view.setTranslationY(-horizontalMargin);
                }
            }
        }
        view.setScaleX(scale);
        view.setScaleY(scale);
        view.setAlpha(MIN_ALPHA + (1 - MIN_ALPHA) * percent);
    } else { // (1,+Infinity]page is way off-screen to the right.
        view.setAlpha(MIN_ALPHA);
        view.setScaleX(MIN_SCALE);
        view.setScaleY(MIN_SCALE);
    }
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:35,代碼來源:TestPageTransformer.java

示例15: getBasicValues

import android.view.View; //導入方法依賴的package包/類
private void getBasicValues(int firstVisibleItem) {
    View firstChild = getChildAt(0);
    mFirstLeft = getListPaddingLeft();
    mFirstTop = firstChild.getTop();
    mColumnWidth = firstChild.getWidth();
    mRowHeight = firstChild.getHeight();
    int rowLine = firstVisibleItem / mColumnsNum;
    mScrollY = mFirstTop - rowLine * (mVerticalSpacing + mRowHeight);
}
 
開發者ID:huxq17,項目名稱:HandyGridView,代碼行數:10,代碼來源:HandyGridView.java


注:本文中的android.view.View.getHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。