本文整理了Java中android.widget.Button.getViewTreeObserver()
方法的一些代码示例,展示了Button.getViewTreeObserver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.getViewTreeObserver()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:getViewTreeObserver
暂无
代码示例来源:origin: stackoverflow.com
final Button tv = (Button)findViewById(R.id.saveit);
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() {
ViewGroup.MarginLayoutParams vlp = (MarginLayoutParams) tv.getLayoutParams();
int btnsize =tv.getMeasuredHeight()+vlp.topMargin;
sizeit(btnsize);
ViewTreeObserver obs = tv.getViewTreeObserver();
obs.removeGlobalOnLayoutListener(this);
}
});
代码示例来源:origin: PopFisher/SmartPopupWindow
private void initViewListener() {
mAnchorBtn.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
if (mPopupWindow == null || !mPopupWindow.isShowing()) {
return;
}
updatePopupPos();
}
});
}
代码示例来源:origin: stackoverflow.com
final Button button1 = (Button) view.findViewById(R.id.button);
final CollapseAnimator animator = new CollapseAnimator(topLayout);
final ViewTreeObserver.OnGlobalLayoutListener listener = new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int mHeight = button1.getMeasuredHeight();
KLog.i("onGlobalLayout() mHeight:" + mHeight);
animator.setValues(mHeight*2, mHeight);
}
};
button1.getViewTreeObserver().addOnGlobalLayoutListener(listener);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
view.post(new Runnable() {
@Override
public void run() {
button1.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
animator.collapse();
}
});
}
});
内容来源于网络,如有侵权,请联系作者删除!