本文整理匯總了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);
}
}
});
}