本文整理汇总了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));
}
}
});
}
示例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);
}
}
});
}