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


Java NestedScrollView类代码示例

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


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

示例1: viewInitialize

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
public void viewInitialize()
{
    mainListView = (ListView) findViewById(R.id.listview);
    scrollview = (NestedScrollView) findViewById(R.id.scrollview);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Log.e("PlayListFragment", i+"/"+l);
            global.playMusic(Integer.parseInt(playList.get(i)));
        }
    });
    mainListView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event)
        {
            scrollview.requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

}
 
开发者ID:icaynia,项目名称:pracler,代码行数:22,代码来源:PlayListActivity.java

示例2: scrollTo

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
public static void scrollTo(Object scroll, float yOffset) {
    if (scroll instanceof RecyclerView) {
        //RecyclerView.scrollTo : UnsupportedOperationException
        //Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
        //Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
        final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
        if (layoutManager instanceof LinearLayoutManager) {
            LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
            linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
            staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
        }
    } else if (scroll instanceof NestedScrollView) {
        ((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:Utils.java

示例3: fling

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
public boolean fling(int velocity) {
    if (mScrollableView instanceof ScrollView) {
        ((ScrollView) mScrollableView).fling(velocity);
    } else if (mScrollableView instanceof AbsListView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ((AbsListView) mScrollableView).fling(velocity);
        }
    } else if (mScrollableView instanceof WebView) {
        ((WebView) mScrollableView).flingScroll(0, velocity);
    } else if (mScrollableView instanceof RecyclerView) {
        ((RecyclerView) mScrollableView).fling(0, velocity);
    } else if (mScrollableView instanceof NestedScrollView) {
        ((NestedScrollView) mScrollableView).fling(velocity);
    } else {
        return false;
    }
    return true;
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:20,代码来源:RefreshContentWrapper.java

示例4: onCreate

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    );
    setContentView(R.layout.activity_scroll_and_navigation);

    final NestedScrollView nestedScrollView = findViewById(R.id.scrollview);

    final AppBarLayout appBarLayout = findViewById(R.id.appbar);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle("Wow");

    ScrimInsetsFrameLayout scrimInsetsFrameLayout = findViewById(R.id.root_insets);
    scrimInsetsFrameLayout.setOnInsetsCallback(new OnInsetsCallback() {
        @Override
        public void onInsetsChanged(Rect insets) {
            appBarLayout.setPadding(0, insets.top, 0, 0);
            nestedScrollView.setPadding(0, 0, 0, insets.bottom);
        }
    });
}
 
开发者ID:Commit451,项目名称:ScrimInsetsLayout,代码行数:27,代码来源:ScrollAndNavigationActivity.java

示例5: flingCompat

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
public static void flingCompat(View view, int velocityY) {
    if (view instanceof ScrollView) {
        ((ScrollView) view).fling(velocityY);
    } else if (view instanceof WebView) {
        ((WebView) view).flingScroll(0, velocityY);
    } else if (view instanceof RecyclerView) {
        ((RecyclerView) view).fling(0, velocityY);
    } else if (view instanceof NestedScrollView) {
        ((NestedScrollView) view).fling(velocityY);
    } else if (view instanceof AbsListView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ((AbsListView) view).fling(velocityY);
        } else {
            SRReflectUtil.compatOlderAbsListViewFling((AbsListView) view, velocityY);
        }
    }
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:18,代码来源:ScrollCompat.java

示例6: onScrollChange

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override public void onScrollChange(NestedScrollView v, int x, int y, int oldx, int oldy) {
  if (y <= 0) {   //设置标题的背景颜色
    llGoodDetail.setBackgroundColor(Color.argb(0, 255, 255, 255));
    line.setVisibility(View.GONE);
    tvGoodDetailTitleGood.setTextColor(Color.TRANSPARENT);
  } else if (y > 0 && y <= height) { //滑动距离小于banner图的高度时,设置背景和字体颜色颜色透明度渐变
    float scale = (float) y / height;
    float alpha = (255 * scale);
    tvGoodDetailTitleGood.setTextColor(Color.argb((int) alpha, 1, 24, 28));
    llGoodDetail.setBackgroundColor(Color.argb((int) alpha, 255, 255, 255));
    line.setVisibility(View.GONE);
  } else {    //滑动到banner下面设置普通颜色
    llGoodDetail.setBackgroundColor(Color.argb(255, 255, 255, 255));
    line.setVisibility(View.VISIBLE);
  }
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:17,代码来源:GoodsDetailActivity.java

示例7: onNestedFling

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
                             float velocityX, float velocityY, boolean consumed) {

    if (target instanceof RecyclerView && velocityY < 0) {
        Log.d(TAG, "onNestedFling: target is recyclerView");
        final RecyclerView recyclerView = (RecyclerView) target;
        final View firstChild = recyclerView.getChildAt(0);
        final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
        consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
    }

    // prevent fling flickering when going up
    if (target instanceof NestedScrollView && velocityY > 0) {
        consumed = true;
    }

    if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
        velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
    }
    Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);

    return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
 
开发者ID:vipulyaara,项目名称:betterHotels,代码行数:25,代码来源:FlingBehavior.java

示例8: initDynamicTitle

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
private void initDynamicTitle() {
    mRlTopContainer.measure(0, 0);
    mLlTitle.measure(0, 0);
    final int topHeight = mRlTopContainer.getMeasuredHeight() - mLlTitle.getMeasuredHeight();

    mScStarDetail.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            float scale = (float) v.getScrollY() / topHeight;

            //变化范围0-255 表示从透明到纯色背景
            float alpha = scale * 255 >= 255 ? 255 : scale * 255;

            mLlTitle.setBackgroundColor(Color.argb((int) alpha, 0, 153, 204));
            mTvTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
            mTvSubTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
        }
    });
}
 
开发者ID:coderwjq,项目名称:ZhaZhaShop,代码行数:20,代码来源:MovieStarActivity.java

示例9: initListener

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
private void initListener() {
    //finish
    getView().toolBar.setNavigationOnClickListener(view -> getView().onBackPressed());
    //
    getView().nsvTitle.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            scrollChangeHeader(scrollY);
        }
    });
    getView().llLoading.setOnReloadListener(v -> {
        if (JUtils.isNetWorkAvilable())
            //onClick
            initData();
    });
    getView().toolBar.setOnMenuItemClickListener(item -> {
        if (item.getItemId() == R.id.actionbar_more) {
            WebViewActivity.startAction(getView(), positionData.getAlt());
        }
        return false;
    });
}
 
开发者ID:zhao-mingjian,项目名称:qvod,代码行数:23,代码来源:MovieDetailsPresenter.java

示例10: initData

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
protected void initData() {
    mId = getIntent().getIntExtra(EXTRA_THEME_ID, 0);
    final String name = getIntent().getStringExtra(EXTRA_THEME_NAME);

    mToolbar.setTitle(name);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mZhihuListRecyclerView.setLayoutParams(new NestedScrollView.LayoutParams(
            NestedScrollView.LayoutParams.MATCH_PARENT,
            NestedScrollView.LayoutParams.MATCH_PARENT));
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mZhihuListRecyclerView.setLayoutManager(layoutManager);
    mZhihuListRecyclerView.setAdapter(mThemeListAdapter);
    mPresenter.loadThemesList(mId);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:19,代码来源:ThemeListActivity.java

示例11: initData

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
protected void initData() {
    mColumnAuthorHref = getIntent().getStringExtra(EXTRA_AUTHOR_NAME);
    mToolbar.setTitle(null);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mColumnListRecyclerView.setLayoutParams(new NestedScrollView.LayoutParams(
            NestedScrollView.LayoutParams.MATCH_PARENT,
            NestedScrollView.LayoutParams.MATCH_PARENT));
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mColumnListRecyclerView.setLayoutManager(layoutManager);
    mColumnListRecyclerView.setAdapter(mColumnListAdapter);
    mPresenter.loadColumnAuthorInfo(mColumnAuthorHref);
    mPresenter.loadColumnList(mColumnAuthorHref);
    mIsLiked = mPresenter.isZhiHuColumnAuthorLiked(mColumnAuthorHref);
    mLikeAuthor.setText(getString(mIsLiked ? R.string.zhihu_followed : R.string.zhihu_follow));
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:20,代码来源:ColumnListActivity.java

示例12: onNestedFling

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
                             float velocityX, float velocityY, boolean consumed) {
    if (target instanceof RecyclerView && velocityY < 0) {
        Log.d(TAG, "onNestedFling: target is recyclerView");
        final RecyclerView recyclerView = (RecyclerView) target;
        final View firstChild = recyclerView.getChildAt(0);
        final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
        consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
    }

    // prevent fling flickering when going up
    if (target instanceof NestedScrollView && velocityY > 0) {
        consumed = true;
    }

    if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
        velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
    }
    Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);

    return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:24,代码来源:FlingBehavior.java

示例13: initViews

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
/**
 * This method is to initialize views
 */
private void initViews() {
    nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);

    textInputLayoutName = (TextInputLayout) findViewById(R.id.textInputLayoutName);
    textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
    textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);
    textInputLayoutConfirmPassword = (TextInputLayout) findViewById(R.id.textInputLayoutConfirmPassword);

    textInputEditTextName = (TextInputEditText) findViewById(R.id.textInputEditTextName);
    textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
    textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);
    textInputEditTextConfirmPassword = (TextInputEditText) findViewById(R.id.textInputEditTextConfirmPassword);

    appCompatButtonRegister = (AppCompatButton) findViewById(R.id.appCompatButtonRegister);

    appCompatTextViewLoginLink = (AppCompatTextView) findViewById(R.id.appCompatTextViewLoginLink);

}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:22,代码来源:RegisterActivity.java

示例14: initWidgets

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
private void initWidgets() {
    View view = LayoutInflater.from(getContext())
            .inflate(R.layout.view_tab_picker, this, false);

    mRecyclerActive = (RecyclerView) view.findViewById(R.id.view_recycler_active);
    mRecyclerInactive = (RecyclerView) view.findViewById(R.id.view_recycler_inactive);
    mViewScroller = (NestedScrollView) view.findViewById(R.id.view_scroller);
    mLayoutTop = (RelativeLayout) view.findViewById(R.id.layout_top);
    mViewWrapper = (LinearLayout) view.findViewById(R.id.view_wrapper);
    mViewDone = (TextView) view.findViewById(R.id.tv_done);
    mViewOperator = (TextView) view.findViewById(R.id.tv_operator);
    mLayoutWrapper = (LinearLayout) view.findViewById(R.id.layout_wrapper);
    mViewDone.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mViewDone.getText().toString().equals("排序删除")) {
                mActiveAdapter.startEditMode();
            } else {
                mActiveAdapter.cancelEditMode();
            }
        }
    });

    addView(view);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:26,代码来源:TabPickerView.java

示例15: prepareUI

import android.support.v4.widget.NestedScrollView; //导入依赖的package包/类
/**
 * 准备UI
 */
private void prepareUI() {
    mViewPager = (ViewPager) findViewById(R.id.vp_photo_detail_viewPager);
    mTopLayout = findViewById(R.id.ll_photo_detail_top_layout);
    mPageTextView = (TextView) findViewById(R.id.tv_photo_detail_page);
    mReportTextView = (TextView) findViewById(R.id.tv_photo_detail_report);
    mProgressBar = (ProgressBar) findViewById(R.id.pb_photo_detail_progressbar);
    mBottomLayout = findViewById(R.id.ll_photo_detail_bottom_layout);
    mCaptionScriollView = (NestedScrollView) findViewById(R.id.nsv_photo_detail_caption_scrollview);
    mCaptionTextView = (TextView) findViewById(R.id.tv_photo_detail_caption);
    mBackButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_back);
    mEditButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_edit);
    mCommentButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_comment);
    mCollectionButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_collection);
    mShareButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_share);
    mPlnumTextView = (TextView) findViewById(R.id.tv_photo_detail_plnum);

    // 监听点击事件
    mReportTextView.setOnClickListener(this);
    mBackButton.setOnClickListener(this);
    mEditButton.setOnClickListener(this);
    mCommentButton.setOnClickListener(this);
    mCollectionButton.setOnClickListener(this);
    mShareButton.setOnClickListener(this);

}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:29,代码来源:PhotoDetailActivity.java


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