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


Java RelativeLayout.getViewTreeObserver方法代碼示例

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


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

示例1: setViewTreeObserver

import android.widget.RelativeLayout; //導入方法依賴的package包/類
private void setViewTreeObserver() {
    mBodyLayout = (RelativeLayout) findViewById(R.id.contentLayout);
    final ViewTreeObserver swipeRefreshLayoutVTO = mBodyLayout.getViewTreeObserver();
    swipeRefreshLayoutVTO.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {

            Rect r = new Rect();
            mBodyLayout.getWindowVisibleDisplayFrame(r);
            int statusBarH =  getStatusBarHeight();
            int screenH = mBodyLayout.getRootView().getHeight();
            if(r.top != statusBarH ){
                r.top = statusBarH;
            }
            int keyboardH = screenH - (r.bottom - r.top);

            if(keyboardH == mCurrentKeyboardH){
                return;
            }

            mCurrentKeyboardH = keyboardH;
            mScreenHeight = screenH;
            mEditTextBodyHeight = mCet.getHeight();

            if(keyboardH<150){
                updateEditTextBodyVisible(View.GONE, null);
                return;
            }
            if(mLayoutManager!=null && mCommentConfig != null){
                mLayoutManager.scrollToPositionWithOffset(mCommentConfig.mBnPosition + BNAdapter.HEADVIEW_SIZE, getRecycleViewOffset(mCommentConfig));
            }
        }
    });
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:35,代碼來源:BlackboardFragmentLayout.java

示例2: onCreate

import android.widget.RelativeLayout; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mStackCards = new ArrayList<ArrayList<CardView>>();
    mStackCards.add(new ArrayList<CardView>());
    mStackCards.add(new ArrayList<CardView>());

    mIsStackEnabled = new boolean[2];
    mIsStackEnabled[0] = true;
    mIsStackEnabled[1] = true;

    mVerticalPadding = getResources().getInteger(R.integer.vertical_card_magin);
    mHorizontalPadding = getResources().getInteger(R.integer.horizontal_card_magin);

    gDetector = new GestureDetector(this, mGestureListener);

    mLayout = (RelativeLayout)findViewById(R.id.main_relative_layout);
    ViewTreeObserver observer = mLayout.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                mLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            } else {
                mLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }

            mCardHeight = mLayout.getHeight();
            mCardWidth = mLayout.getWidth() / 2;

            for (int x = 0; x < STARTING_NUMBER_CARDS; x++) {
                addNewCard(RIGHT_STACK);
            }
        }
    });
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:39,代碼來源:CardFlip.java


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