当前位置: 首页>>代码示例>>Java>>正文


Java NestedScrollView.setOnScrollChangeListener方法代码示例

本文整理汇总了Java中android.support.v4.widget.NestedScrollView.setOnScrollChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java NestedScrollView.setOnScrollChangeListener方法的具体用法?Java NestedScrollView.setOnScrollChangeListener怎么用?Java NestedScrollView.setOnScrollChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.NestedScrollView的用法示例。


在下文中一共展示了NestedScrollView.setOnScrollChangeListener方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerScrollView

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
/**
 * Register a ScrollView to the current MaterialViewPagerAnimator
 * Listen to ObservableScrollViewCallbacks so give to $[observableScrollViewCallbacks] your ObservableScrollViewCallbacks if you already use one
 * For loadmore or anything else
 *
 * @param scrollView the scrollable
 */
void registerScrollView(final NestedScrollView scrollView) {
    if (scrollView != null) {
        scrollViewList.add(scrollView);  //add to the scrollable list

        scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {

            boolean firstZeroPassed;

            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                //first time you get 0, don't share it to others scrolls
                if (scrollY == 0 && !firstZeroPassed) {
                    firstZeroPassed = true;
                    return;
                }

                //only if yOffset changed
                if (isNewYOffset(scrollY)) {
                    onMaterialScrolled(scrollView, scrollY);
                }
            }
        });

        scrollView.post(new Runnable() {
            @Override
            public void run() {
                setScrollOffset(scrollView, lastYOffset);
            }
        });
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:MaterialViewPagerAnimator.java

示例2: onCreate

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_goods_details);

    mToolbar = findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
    mHeaderView = findViewById(R.id.header);

    nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            int headerHeight = mHeaderView.getHeight();
            int scrollDistance = Math.min(scrollY, headerHeight);
            int statusAlpha = (int) ((float) scrollDistance / (float) headerHeight * 255F);
            setAnyBarAlpha(statusAlpha);
        }
    });

    Sofia.with(this)
            .statusBarBackground(ContextCompat.getColor(this, R.color.colorPrimary))
            .navigationBarBackground(ContextCompat.getDrawable(this, R.color.colorNavigation))
            .invasionStatusBar()
            .fitsSystemWindowView(mToolbar);

    setAnyBarAlpha(0);
}
 
开发者ID:yanzhenjie,项目名称:Sofia,代码行数:30,代码来源:GoodsDetailsActivity.java

示例3: onCreate

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_common);

    mToolbar = findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
    mHeaderView = findViewById(R.id.header);

    final int startColor = ContextCompat.getColor(this, R.color.colorPrimary);
    final int endColor = ContextCompat.getColor(this, R.color.colorNavigation);

    nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            int headerHeight = mHeaderView.getHeight();
            int scrollDistance = Math.min(scrollY, headerHeight);
            float fraction = (float) scrollDistance / (float) headerHeight;

            setToolbarStatusBarAlpha(evaluate(fraction, startColor, endColor));
            setNavigationViewColor(evaluate(fraction, endColor, startColor));
        }
    });

    Sofia.with(this)
            .statusBarBackground(ContextCompat.getColor(this, R.color.colorPrimary))
            .navigationBarBackground(ContextCompat.getDrawable(this, R.color.colorNavigation));
}
 
开发者ID:yanzhenjie,项目名称:Sofia,代码行数:31,代码来源:CommonActivity.java

示例4: onViewCreated

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  scrollView = (NestedScrollView) view.findViewById(R.id.scrollView);
  payloadTextView = (TextView) getView().findViewById(R.id.payload_text);
  super.onViewCreated(view, savedInstanceState);
  changeLoaderVisibility(View.VISIBLE);
  presenter.init(viewModel, mode);
  scrollView.setOnScrollChangeListener(this);
}
 
开发者ID:jainsahab,项目名称:AndroidSnooper,代码行数:10,代码来源:HttpCallFragment.java

示例5: ViewTooltip

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
private ViewTooltip(MyContext myContext, View view) {
    this.view = view;
    this.tooltip_view = new TooltipView(myContext.getContext());
    final NestedScrollView scrollParent = findScrollParent(view);
    if (scrollParent != null) {
        scrollParent.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                tooltip_view.setTranslationY(tooltip_view.getTranslationY() - (scrollY - oldScrollY));
            }
        });
    }
}
 
开发者ID:florent37,项目名称:ViewTooltip,代码行数:14,代码来源:ViewTooltip.java

示例6: initScrollAnimation

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
private void initScrollAnimation(ViewHolder holder) {
    NestedScrollView scrollView = holder.get(R.id.scroll_view);
    ImageView avatar = holder.get(R.id.avatar);
    TextView username = holder.get(R.id.username);
    View backbground = holder.get(R.id.background);

    this.expectAnimMove = new ExpectAnim()
            .expect(avatar)
            .toBe(
                    topOfParent().withMarginDp(13),
                    leftOfParent().withMarginDp(13),
                    scale(0.5f, 0.5f)
            )
            .expect(username)
            .toBe(
                    toRightOf(avatar).withMarginDp(16),
                    sameCenterVerticalAs(avatar),
                    alpha(0.5f)
            )
            .expect(backbground)
            .toBe(
                    height(DensityUtils.dip2px(this, 60)).withGravity(Gravity.LEFT, Gravity.TOP)
            )
            .toAnimation();

    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int
                oldScrollX, int oldScrollY) {
            final float percent = (scrollY * 1f) / v.getMaxScrollAmount();
            expectAnimMove.setPercent(percent);
        }
    });
}
 
开发者ID:GcsSloop,项目名称:diycode,代码行数:35,代码来源:UserActivity.java

示例7: onCreate

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll_collapse_large_toolbar);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String toolbarTitle = getResources().getString(R.string.sample_collapse_scroll_toolbar);
    CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(toolbarTitle);

    mFab = findViewById(R.id.fab);

    NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.nested_scrollview);
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (scrollY > oldScrollY) {
                animateFab(false);
            } else {
                animateFab(true);
            }
        }
    });
}
 
开发者ID:romainz,项目名称:CoordinatorLayoutSample,代码行数:29,代码来源:ScrollCollapseLargeToolbarActivity.java

示例8: onCreate

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    wearLocker = (WearLocker) getApplicationContext();

    drawerLayout = (WearableDrawerLayout) findViewById(R.id.drawerLayout);
    WearableActionDrawer actionDrawer = (WearableActionDrawer) findViewById(R.id.actionDrawer);
    NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.scrollView);
    enable = findViewById(R.id.enable);
    enableText = (TextView) findViewById(R.id.enableText);
    vibration = findViewById(R.id.vibration);
    vibrationText = (TextView) findViewById(R.id.vibrationText);
    color = findViewById(R.id.color);
    gesture = findViewById(R.id.gesture);
    gestureText = (TextView) findViewById(R.id.gestureText);
    View preview = findViewById(R.id.preview);

    if (Settings.canDrawOverlays(this)) {
        if (wearLocker.isEnabled())
            startService(new Intent(this, OverlayService.class));
    } else {
        startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), REQUEST_SETUP);
        Toast.makeText(this, R.string.msg_overlay_permission, Toast.LENGTH_SHORT).show();
    }

    drawerLayout.peekDrawer(Gravity.BOTTOM);
    actionDrawer.lockDrawerClosed();
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (scrollY == 0 || scrollY < oldScrollY)
                drawerLayout.peekDrawer(Gravity.BOTTOM);
            else drawerLayout.closeDrawer(Gravity.BOTTOM);
        }
    });

    enableText.setText(wearLocker.isEnabled() ? R.string.status_enabled : R.string.status_disabled);
    enable.setOnClickListener(this);

    vibrationText.setText(wearLocker.isVibrate() ? R.string.status_enabled : R.string.status_disabled);
    vibration.setOnClickListener(this);

    color.setBackgroundColor(StaticUtils.getAlphaColor(wearLocker.getColor(), 100));
    color.setOnClickListener(this);

    gestureText.setText(wearLocker.getGestureTitle());
    gesture.setOnClickListener(this);

    preview.setOnClickListener(this);
}
 
开发者ID:TheAndroidMaster,项目名称:WearLocker,代码行数:52,代码来源:MainActivity.java

示例9: bind

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
public static ScrollBindHelper bind (SeekBar seekBar, NestedScrollView scrollView) {
    ScrollBindHelper helper = new ScrollBindHelper(seekBar, scrollView);
    seekBar.setOnSeekBarChangeListener(helper);
    scrollView.setOnScrollChangeListener(helper);
    return helper;
}
 
开发者ID:Lazyeraser,项目名称:DereHelper,代码行数:7,代码来源:ScrollBindHelper.java

示例10: onCreate

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article);
    supplier = (Supplier) getApplicationContext();
    article = getIntent().getParcelableExtra(EXTRA_ARTICLE);

    drawerLayout = (WearableDrawerLayout) findViewById(R.id.drawerLayout);
    WearableActionDrawer actionDrawer = (WearableActionDrawer) findViewById(R.id.actionDrawer);
    NestedScrollView scrollView = (NestedScrollView) findViewById(R.id.scrollView);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    TextView title = (TextView) findViewById(R.id.title);
    content = (TextView) findViewById(R.id.content);
    TextView date = (TextView) findViewById(R.id.date);

    drawerLayout.peekDrawer(Gravity.BOTTOM);
    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (scrollY == 0 || scrollY < oldScrollY)
                drawerLayout.peekDrawer(Gravity.BOTTOM);
            else drawerLayout.closeDrawer(Gravity.BOTTOM);
        }
    });

    title.setText(article.name);
    content.setText(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(article.desc, 0) : Html.fromHtml(article.desc));
    content.setMovementMethod(new WearMovementMethod(this));
    date.setText(article.date);

    actionDrawer.setOnMenuItemClickListener(this);

    MenuItem favoriteItem = actionDrawer.getMenu().findItem(R.id.action_favorite);
    boolean isFavorite = supplier.isFavorite(article);
    favoriteItem.setTitle(isFavorite ? R.string.action_unfavorite : R.string.action_favorite);
    favoriteItem.setIcon(isFavorite ? R.drawable.ic_favorite : R.drawable.ic_favorite_border);

    supplier.getFullContent(article, new Supplier.AsyncListener<String>() {
        @Override
        public void onTaskComplete(String value) {
            if (content != null && progressBar != null) {
                content.setText(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? Html.fromHtml(value, 0) : Html.fromHtml(value));
                progressBar.setVisibility(View.GONE);
            }
        }

        @Override
        public void onFailure() {
            if (progressBar != null)
                progressBar.setVisibility(View.GONE);
        }
    });
}
 
开发者ID:TheAndroidMaster,项目名称:APReader,代码行数:54,代码来源:ArticleActivity.java

示例11: registerWidget

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
protected void registerWidget() {
    note_detail_groupname =$(R.id.note_detail_groupname) ;
    note_detail_groupname.setText(currentNoteInfo.title);
    real_toolbar =$(R.id.real_toolbar) ;
    note_detail_time =$(R.id.note_detail_time) ;
    editFab = $(R.id.edit_fab);

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            showHelp(editFab);
        }
    },1000);

    bindViewsToOnClickListenerById(R.id.note_detail_content,R.id.edit_fab);
    NestedScrollView nestedScrollView = getNestedScrollView();
    if(nestedScrollView == null){
        Log.e(NONoConfig.TAG_NONo,"note detail activity must have at lease one NestedScrollView");
    }else {
        nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                int dy = scrollY - oldScrollY;
                if (dy < 0) {
                    if (magicFlag) {
                        magicFlag = !magicFlag;
                        editFab.setVisibility(View.VISIBLE);
                    }
                } else if (dy > 0) {
                    if (!magicFlag) {
                        magicFlag = !magicFlag;
                        editFab.setVisibility(View.INVISIBLE);
                    }
                }
            }
        });
    }
    //iniFAB();
    if(((TextView)$(R.id.note_detail_text_num)).getText().toString().equals("0")){
        showTextNum(currentNoteInfo.content);
    }
}
 
开发者ID:tianyuan168326,项目名称:nono-android,代码行数:44,代码来源:NoteDetailBaseActivity.java

示例12: setupDialog

import android.support.v4.widget.NestedScrollView; //导入方法依赖的package包/类
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    rootView = View.inflate(getContext(), R.layout.fragment_sheet_properties, null);
    dialog.setContentView(rootView);

    mBundle = getArguments();
    mFile = mBundle.getParcelable(KEY_FILE);
    mPermission = mBundle.getString(KEY_PERMISSION);
    mIsRoot = mBundle.getBoolean(KEY_ROOT);

    mToolbar = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar_layout);
    mAppBarLayout = (AppBarLayout) rootView.findViewById(R.id.appBarLayout);
    mToolbar.setTitle(getString(R.string.properties));
    mToolbar.setCollapsedTitleTextAppearance(R.style.collapsed_appbar);
    mToolbar.setExpandedTitleTextAppearance(R.style.expanded_appbar);

    mFileNameTextView = (TextView) rootView.findViewById(R.id.text_view_file_name);
    mFileNameTextView.setText(mFile.getName());
    mFileTypeTextView = (TextView) rootView.findViewById(R.id.text_view_file_type);
    mFileTypeTextView.setText(mFile.isDirectory() ? getString(R.string.folder) : mFile.getName().substring(mFile.getName().lastIndexOf(".")));
    mFileSizeTextView = (TextView) rootView.findViewById(R.id.text_view_file_size);
    mFileSizeTextView.setText(Formatter.formatFileSize(dialog.getContext(), mFile.isDirectory() ? FileUtils.folderSize(new File(mFile.getPath()), null) : mFile.getSize()));
    mFileLocationTextView = (TextView) rootView.findViewById(R.id.text_view_file_location);
    mFileLocationTextView.setText(mFile.getPath());
    mFileAccessedTextView = (TextView) rootView.findViewById(R.id.text_view_file_accessed);
    mFileAccessedTextView.setText(Utils.getDate(mFile.getDate()));
    mFileModifiedTextView = (TextView) rootView.findViewById(R.id.text_view_file_modified);
    mFileModifiedTextView.setText(Utils.getDate(mFile.getDate()));

    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) rootView.getParent()).getLayoutParams();

    mBottomSheetBehavior = (BottomSheetBehavior) layoutParams.getBehavior();
    mBottomSheetBehavior.setBottomSheetCallback(mCallback);

    mNestedScrollView = (NestedScrollView) rootView.findViewById(R.id.nested_view);

    mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            Log.d(getClass().getSimpleName(), "ScrollY: " + scrollY + " oldScrollY: " + oldScrollY);
            if (scrollY==0) {
                // we're at the top
                mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
            }
        }
    });


    /*Bitmap bitmap = BitmapFactory.decodeFile(mFile.getPath());
    Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
        @Override
        public void onGenerated(Palette palette) {
            mToolbarLayout.setContentScrimColor(palette.getMutedColor());
            mToolbarLayout.setStatusBarScrimColor(palette.getMutedColor());
        }
    });*/
}
 
开发者ID:TeamAmaze,项目名称:AmazeFileManager,代码行数:59,代码来源:PropertiesSheet.java


注:本文中的android.support.v4.widget.NestedScrollView.setOnScrollChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。