本文整理了Java中android.widget.ScrollView.getViewTreeObserver()
方法的一些代码示例,展示了ScrollView.getViewTreeObserver()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollView.getViewTreeObserver()
方法的具体详情如下:
包路径:android.widget.ScrollView
类名称:ScrollView
方法名:getViewTreeObserver
暂无
代码示例来源:origin: Aspsine/SwipeToLoadLayout
@Override
public void onDestroyView() {
scrollView.getViewTreeObserver().removeOnScrollChangedListener(mOnScrollChangedListener);
super.onDestroyView();
}
代码示例来源:origin: Aspsine/SwipeToLoadLayout
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
scrollView = (ScrollView) view.findViewById(R.id.swipe_target);
tvTitle = (TextView) view.findViewById(R.id.tvTitle);
ViewGroup viewGroup = (ViewGroup) view.findViewById(R.id.group);
// use this method find view is not an good way.
// do not learn! do not learn! do not learn! important thing say three times. :)
ivArray = new ImageView[viewGroup.getChildCount()];
for (int i = 0; i < viewGroup.getChildCount(); i++) {
ivArray[i] = (ImageView) viewGroup.getChildAt(i);
}
swipeToLoadLayout.setOnRefreshListener(this);
swipeToLoadLayout.setOnLoadMoreListener(this);
scrollView.getViewTreeObserver().addOnScrollChangedListener(mOnScrollChangedListener);
}
代码示例来源:origin: rey5137/material
mWeekView = (WeekView)v.findViewById(R.id.rd_wv_week);
sv_repeat.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
代码示例来源:origin: stackoverflow.com
ScrollView scrollView = (ScrollView)findViewById(R.id.svtest);
ViewTreeObserver vto = scrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < 16)
scrollView.getViewTreeObserver().removeGlobalOnLayoutListener(listener);
else
scrollView.getViewTreeObserver().removeOnGlobalLayoutListener(listener);
int width = scrollView.getMeasuredWidth();
int height = scrollView.getMeasuredHeight();
// postpone any calculation depend on it to here.
// regardless what it is. UI or http connection.
}
});
代码示例来源:origin: stackoverflow.com
ScrollView scrollView = (ScrollView)findViewById(R.id...);
ViewTreeObserver observer = scrollView.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int viewHeight = scrollView.getMeasuredHeight();
int contentHeight = scrollView.getChildAt(0).getHeight();
if(viewHeight - contentHeight < 0) {
// scrollable
}
}
});
代码示例来源:origin: hefuyicoder/ZhihuDaily
private void addScrollListener() {
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
if (!isAdded()) {
return;
}
changeHeaderPosition();
changeToolbarAlpha();
}
});
}
代码示例来源:origin: luhaoaimama1/zone-sdk
@Override
public boolean onPreDraw() {
sv.getViewTreeObserver().removeOnPreDrawListener(this);
System.out.println("ViewTreeObserver:onPreDraw");
//todo true的时候 能看到页面 false直接卡死了
return true;
}
};
代码示例来源:origin: animalize/QuanTangshi
@Override
public void onGlobalLayout() {
setYPosi(posi);
// 去掉监听器,因为输入法也会触发这里
final ViewTreeObserver observer = root.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
observer.removeOnGlobalLayoutListener(this);
} else {
observer.removeGlobalOnLayoutListener(this);
}
}
代码示例来源:origin: antest1/kcanotify
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
ViewTreeObserver observer = fleetMenu.getViewTreeObserver();
observer.addOnScrollChangedListener(fleetMenuScrollChangeListener);
return false;
}
});
代码示例来源:origin: luhaoaimama1/zone-sdk
@Override
public void onGlobalLayout() {
sv.getViewTreeObserver().removeOnGlobalLayoutListener(this);
System.out.println("ViewTreeObserver:OnGlobalLayoutListener"
+ "->可见性:" + (sv.getVisibility() == View.VISIBLE ? "可见" : "不可见"));
}
});
代码示例来源:origin: stackoverflow.com
ScrollView scrollView = (ScrollView)findViewById(R.id.contentScrollView);
ImageView imageView = (ImageView)findViewById(R.id.contentImageView);
ViewTreeObserver vto = scrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
scrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
int width = scrollView.getMeasuredWidth();
int height = scrollView.getMeasuredHeight();
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(layoutParams.MATCH_PARENT, height * 0.8f);
imageView.setLayoutParams(layoutParams);
}
});
代码示例来源:origin: stackoverflow.com
final ScrollView myScroll = (ScrollView)findViewById(R.id.my_scroll);
ViewTreeObserver vto = myScroll.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
LayerDrawable ld = (LayerDrawable)myScroll.getBackground();
height = myScroll.getHeight();
width=myScroll.getHeight();
ViewTreeObserver obs = myScroll.getViewTreeObserver();
obs.removeOnGlobalLayoutListener(this);
}
});
代码示例来源:origin: xbmc/Kore
@Override
public void onDestroyView() {
mediaPanel.getViewTreeObserver().removeOnScrollChangedListener(this);
super.onDestroyView();
unbinder.unbind();
}
代码示例来源:origin: byhieg/easyweather
@Override
public void onResume() {
super.onResume();
if (scrollView != null) {
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
if (mSwipeLayout != null) {
mSwipeLayout.setEnabled(scrollView.getScrollY() == 0);
}
}
});
}
}
代码示例来源:origin: xbmc/Kore
@Override
public void onActivityCreated (Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setHasOptionsMenu(false);
/** Setup dim the fanart when scroll changes
* Full dim on 4 * iconSize dp
* @see {@link #onScrollChanged()}
*/
pixelsToTransparent = 4 * getActivity().getResources().getDimensionPixelSize(R.dimen.default_icon_size);
mediaPanel.getViewTreeObserver().addOnScrollChangedListener(this);
}
代码示例来源:origin: stackoverflow.com
private ScrollView mScroll;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_history);
mScroll = (ScrollView) findViewById(R.id.scroll_view);
ViewTreeObserver vto = mScroll.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mScroll.getViewTreeObserver().removeGlobalOnLayoutListener(this);
int scrollHeight = mScroll.getChildAt(0).getMeasuredHeight();
mScroll.scrollTo(0, scrollHeight);
}
});
}
@Override
protected void onResume() {
super.onResume();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mScroll.smoothScrollTo(0, 0);
}
}, 800);
}
代码示例来源:origin: chendongMarch/LightAdapter
@BindingAdapter(value = {"bindScroll"})
public static void onScrollChangeCommand(
final ScrollView scrollView,
final ViewTreeObserver.OnScrollChangedListener onScrollChangedListener) {
scrollView.getViewTreeObserver().addOnScrollChangedListener(() -> {
if (onScrollChangedListener != null) {
onScrollChangedListener.onScrollChanged();
}
});
}
}
代码示例来源:origin: stackoverflow.com
public class MainActivityList extends Activity {
ScrollView scroll1, scroll2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_activity_list);
ListView list_1 = (ListView) findViewById(R.id.list_1);
// Set list_1 Adapter
SetListOneHeight.setListViewHeight(list_1);
ListView list_2 = (ListView) findViewById(R.id.list_2);
// Set list_2 Adapter
SetListTwoHeight.setListViewHeight(list_2);
scroll1 = (ScrollView) findViewById(R.id.scroll1);
scroll2 = (ScrollView) findViewById(R.id.scroll2);
scroll1.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
int scrollY = scroll1.getScrollY();
scroll2.scrollTo(0, scrollY);
}
});
}
}
代码示例来源:origin: ywwynm/EverythingDone
@Override
protected void setEvents() {
mScrollView.getViewTreeObserver().addOnScrollChangedListener(
new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
updateFabState();
updateActionbarState();
}
});
mFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doWithPermissionChecked(
new SimplePermissionCallback(StatisticActivity.this) {
@Override
public void onGranted() {
startScreenshot();
}
},
Def.Communication.REQUEST_PERMISSION_SCREENSHOT,
Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
});
}
代码示例来源:origin: alphamu/FrostyBackgroundTestApp
mBinding.scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
内容来源于网络,如有侵权,请联系作者删除!