本文整理匯總了Java中android.view.ViewTreeObserver.OnScrollChangedListener類的典型用法代碼示例。如果您正苦於以下問題:Java OnScrollChangedListener類的具體用法?Java OnScrollChangedListener怎麽用?Java OnScrollChangedListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OnScrollChangedListener類屬於android.view.ViewTreeObserver包,在下文中一共展示了OnScrollChangedListener類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initView
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
private void initView() {
this.scrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
int HEIGHT = RadarActivity.this.getResources().getDisplayMetrics().heightPixels;
int[] area = new int[2];
public void onScrollChanged() {
RadarActivity.this.nutritionLayout.getLocationOnScreen(this.area);
if (this.area[1] + RadarActivity.this.nutritionLayout.getHeight() < this.HEIGHT) {
RadarActivity.this.nutritionLayout.startAnim();
}
RadarActivity.this.sportLayout.getLocationOnScreen(this.area);
if (this.area[1] + RadarActivity.this.sportLayout.getHeight() < this.HEIGHT) {
RadarActivity.this.sportLayout.startAnim();
}
RadarActivity.this.ringNutrition.getLocationOnScreen(this.area);
if (this.area[1] + RadarActivity.this.ringNutrition.getHeight() < this.HEIGHT) {
RadarActivity.this.ringNutrition.startAnim();
}
RadarActivity.this.ringHeat.getLocationInWindow(this.area);
if (this.area[1] + RadarActivity.this.ringHeat.getHeight() < this.HEIGHT) {
RadarActivity.this.ringHeat.startAnim();
}
}
});
}
示例2: setScrollView
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
private void setScrollView(){
sv.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
@Override
public void onScrollChanged() {
int scrollY = sv.getScrollY(); //for verticalScrollView
mHeader.setTranslationY(Math.max(-scrollY, mMinHeaderTranslation));
//header_logo --> actionbar icon
float ratio = clamp(mHeader.getTranslationY() / mMinHeaderTranslation, 0.0f, 1.0f);
interpolate(mHeaderLogo, getActionBarIconView(), mSmoothInterpolator.getInterpolation(ratio));
interpolate2(sp, getActionBarIconView(), mSmoothInterpolator.getInterpolation(ratio));
//actionbar title alpha
//getActionBarTitleView().setAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F));
//---------------------------------
//better way thanks to @cyrilmottier
setTitleAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F));
}
});
}
示例3: init
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
private void init() {
if (superListenerField != null) {
try {
mSuperScrollListener = (OnScrollChangedListener) superListenerField.get(this);
superListenerField.set(this, NOP);
} catch (Exception e) {
mSuperScrollListener = null;
}
}
}
示例4: m2531a
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
private static void m2531a(PopupWindow popupWindow) {
try {
Field declaredField = PopupWindow.class.getDeclaredField("mAnchor");
declaredField.setAccessible(true);
Field declaredField2 = PopupWindow.class.getDeclaredField("mOnScrollChangedListener");
declaredField2.setAccessible(true);
declaredField2.set(popupWindow, new ba(declaredField, popupWindow, (OnScrollChangedListener) declaredField2.get(popupWindow)));
} catch (Throwable e) {
Log.d("AppCompatPopupWindow", "Exception while installing workaround OnScrollChangedListener", e);
}
}
示例5: call
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
@Override
public void call(final Subscriber<? super ViewScrollChangeEvent> subscriber) {
final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
final OnScrollChangedListener listener = new OnScrollChangedListener() {
int oldX, oldY;
@Override
public void onScrollChanged() {
if (!subscriber.isUnsubscribed()) {
int scrollX = view.getScrollX();
int scrollY = view.getScrollY();
subscriber.onNext(ViewScrollChangeEvent.create(view, scrollX, scrollY, oldX, oldY));
oldX = scrollX;
oldY = scrollY;
}
}
};
viewTreeObserver.addOnScrollChangedListener(listener);
subscriber.add(new MainThreadSubscription() {
@Override
protected void onUnsubscribe() {
viewTreeObserver.removeOnScrollChangedListener(listener);
}
});
}
示例6: zza
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
public static void zza(Activity paramActivity, ViewTreeObserver.OnScrollChangedListener paramOnScrollChangedListener)
{
Window localWindow = paramActivity.getWindow();
if ((localWindow != null) && (localWindow.getDecorView() != null) && (localWindow.getDecorView().getViewTreeObserver() != null)) {
localWindow.getDecorView().getViewTreeObserver().addOnScrollChangedListener(paramOnScrollChangedListener);
}
}
示例7: zzb
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
public static void zzb(Activity paramActivity, ViewTreeObserver.OnScrollChangedListener paramOnScrollChangedListener)
{
Window localWindow = paramActivity.getWindow();
if ((localWindow != null) && (localWindow.getDecorView() != null) && (localWindow.getDecorView().getViewTreeObserver() != null)) {
localWindow.getDecorView().getViewTreeObserver().removeOnScrollChangedListener(paramOnScrollChangedListener);
}
}
示例8: IncognitoBottomSheetContent
import android.view.ViewTreeObserver.OnScrollChangedListener; //導入依賴的package包/類
/**
* Constructs a new IncognitoBottomSheetContent.
* @param activity The {@link Activity} displaying this bottom sheet content.
*/
public IncognitoBottomSheetContent(final Activity activity) {
LayoutInflater inflater = LayoutInflater.from(activity);
mView = inflater.inflate(R.layout.incognito_bottom_sheet_content, null);
View learnMore = mView.findViewById(R.id.learn_more);
learnMore.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
HelpAndFeedback.getInstance(activity).show(activity,
activity.getString(R.string.help_context_incognito_learn_more),
Profile.getLastUsedProfile(), null);
}
});
final FadingShadowView shadow = (FadingShadowView) mView.findViewById(R.id.shadow);
shadow.init(
ApiCompatibilityUtils.getColor(mView.getResources(), R.color.toolbar_shadow_color),
FadingShadow.POSITION_TOP);
mScrollView = (ScrollView) mView.findViewById(R.id.scroll_view);
mScrollView.getViewTreeObserver().addOnScrollChangedListener(new OnScrollChangedListener() {
@Override
public void onScrollChanged() {
boolean shadowVisible = mScrollView.canScrollVertically(-1);
shadow.setVisibility(shadowVisible ? View.VISIBLE : View.GONE);
}
});
}