当前位置: 首页>>代码示例>>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;未经允许,请勿转载。