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


Java AppBarLayout.addOnOffsetChangedListener方法代码示例

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


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

示例1: initView

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void initView() {
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.hide();
    }
    searchbarview = (SearchBarView) findViewById(R.id.searchbarview);
    searchbarview.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // enter search activity
            Toast.makeText(MainActivity.this, "enter search activity", Toast.LENGTH_SHORT).show();
        }
    });
    AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbarlayout);
    appBarLayout.addOnOffsetChangedListener(this);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setVerticalScrollBarEnabled(true);
    mRecyclerView.setNestedScrollingEnabled(false);
    mRecyclerView.setAdapter(new MyAdapter());
}
 
开发者ID:yuqirong,项目名称:FlexibleSearchBar,代码行数:23,代码来源:MainActivity.java

示例2: setAppbarEvent

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void setAppbarEvent() {
    AppBarLayout appBar = (AppBarLayout) getParent();

    if (appBar.getParent().getClass().equals(CoordinatorLayout.class)) {
        CoordinatorLayout rootLayout = (CoordinatorLayout) appBar.getParent();

        View tabs = getChildAt(0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            tabs.setElevation(getResources().getDimensionPixelOffset(R.dimen.tabs_elevation));
        }

        removeView(tabs);
        rootLayout.addView(tabs);

        getLayoutParams().height = getResources().getDimensionPixelOffset(R.dimen.fancy_tab_layout_height);
        requestLayout();
        isFloating = true;
    }

    appBar.addOnOffsetChangedListener(onOffsetChangedListener);
}
 
开发者ID:ypicoleal,项目名称:FancyTab,代码行数:22,代码来源:FancyTabLayout.java

示例3: init

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
/**
 * 初始化,关联AppBarLayout,处理滑动冲突
 * @param refreshLayout
 * @param appBar
 * @param listener
 */
public static void init(final SwipeRefreshLayout refreshLayout, AppBarLayout appBar, SwipeRefreshLayout.OnRefreshListener listener) {
    refreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);
    refreshLayout.setOnRefreshListener(listener);
    appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (verticalOffset >= 0) {
                refreshLayout.setEnabled(true);
            } else {
                refreshLayout.setEnabled(false);
            }
        }
    });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:SwipeRefreshHelper.java

示例4: onDependentViewChanged

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FrameLayout child, View dependency) {
    AppBarLayout barLayout = (AppBarLayout) dependency;
    if (isFirst) {
        initView(parent);
        initPosition();
        barLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                Log.e(TAG, "verticalOffset = " + verticalOffset);
                Log.e(TAG, "AppBarLayout = " + appBarLayout.getX());
                scrollY(verticalOffset, appBarLayout.getTotalScrollRange());
            }
        });
        isFirst = false;
    }
    return true;
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:19,代码来源:CoustomBehavier.java

示例5: onAttached

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onAttached(SmoothRefreshLayout layout) {
    CoordinatorLayout coordinatorLayout = findCoordinatorLayout(layout);
    if (coordinatorLayout == null)
        return;
    AppBarLayout appBarLayout = findAppBarLayout(coordinatorLayout);
    if (appBarLayout == null)
        return;
    appBarLayout.addOnOffsetChangedListener(this);
    layout.setOnChildNotYetInEdgeCannotMoveHeaderCallBack(this);
    layout.setOnChildNotYetInEdgeCannotMoveFooterCallBack(this);
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:13,代码来源:QuickConfigAppBarUtil.java

示例6: initSelfView

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void initSelfView() {
    toolbar = (Toolbar) findViewById(R.id.sheet_detail_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toTop = (FloatingActionButton) findViewById(R.id.sheet_detail_top);
    initToTopPos();

    songList = (RecyclerView) findViewById(R.id.sheet_detail_songs_list);
    appBarLayout = (AppBarLayout) findViewById(R.id.sheet_detail_app_bar);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.sheet_detail_toolbar_layout);
    barStateChangeListener = new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state) {
            switch (state) {
                case EXPANDED:
                    collapsingToolbarLayout.setTitle(" ");
                    songList.setNestedScrollingEnabled(false);
                    transToTopBt(true);
                    break;
                case COLLAPSED:
                    collapsingToolbarLayout.setTitle(infoController.getTitle());
                    songList.setNestedScrollingEnabled(true);
                    toTop.setVisibility(View.VISIBLE);
                    transToTopBt(false);
                    break;
                case IDLE:
                    collapsingToolbarLayout.setTitle(" ");
                    break;
            }
        }
    };
    appBarLayout.addOnOffsetChangedListener(barStateChangeListener);

}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:36,代码来源:SheetDetailActivity.java

示例7: initViews

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void initViews() {
        mIndicator = (SimpleViewPagerIndicator) findViewById(R.id.id_stickynavlayout_indicator);
        mViewPager = (ViewPager) findViewById(R.id.id_stickynavlayout_viewpager);
        textView = (ImageView) findViewById(R.id.textView);
        textView1 = (ImageView) findViewById(R.id.textView1);
        title = (ImageView) findViewById(R.id.title);
        title1 = (ImageView) findViewById(R.id.title1);
        bifen1 = (TextView) findViewById(R.id.bifen1);
        bifen2 = (TextView) findViewById(R.id.bifen2);
        bifen3 = (TextView) findViewById(R.id.bifen3);
        bifen = (TextView) findViewById(R.id.bifen);
        mAppBar = (AppBarLayout) findViewById(R.id.appbar);
        mAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
//                scrollY(verticalOffset, appBarLayout.getTotalScrollRange());
                Log.e(TAG, "onOffsetChanged: " + verticalOffset);
            }
        });
        zhudui = (FrameLayout) findViewById(R.id.zhudui);
        kedui = (FrameLayout) findViewById(R.id.kedui);
        bifenlayout = (FrameLayout) findViewById(R.id.bifenlayout);
        bifen1layout = (RelativeLayout) findViewById(R.id.bifen1layout);

        toolbarTitle = (RelativeLayout) findViewById(R.id.toolbar_title);

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

    }
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:32,代码来源:CoordinatorLayoutActivity.java

示例8: initView

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void initView() {
    bifen_guest = (TextView) findViewById(R.id.bifen_guest);
    bifen_guest_back = (TextView) findViewById(R.id.bifen_guest_back);
    bifen_host = (TextView) findViewById(R.id.bifen_host);
    bifen_host_back = (TextView) findViewById(R.id.bifen_host_back);
    guest_name = (TextView) findViewById(R.id.guest_name);
    guest_name_back = (TextView) findViewById(R.id.guest_name_back);
    host_name = (TextView) findViewById(R.id.host_name);
    host_name_back = (TextView) findViewById(R.id.host_name_back);
    status_header_back = (TextView) findViewById(R.id.status_header_back);
    match_time = (TextView) findViewById(R.id.match_time);
    match_data = (TextView) findViewById(R.id.match_data);
    tv_kedui = (TextView) findViewById(R.id.tv_kedui);
    tv_zhudui = (TextView) findViewById(R.id.tv_zhudui);
    status_match = (TextView) findViewById(R.id.status_match);
    zhibo = (ImageView) findViewById(R.id.zhibo);
    image_guest = (ImageView) findViewById(R.id.image_guest);
    image_host = (ImageView) findViewById(R.id.image_host);
    mAppBar = (AppBarLayout) findViewById(R.id.appbar);
    mAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            scrollY(verticalOffset, appBarLayout.getTotalScrollRange());
        }
    });

    MathchProgressView = (MathchProgressView) findViewById(R.id.MathchProgressView);
    MathchProgressView.setProgress(0);
    handler.sendEmptyMessageDelayed(0, 1000);
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:31,代码来源:TextViewActivity.java

示例9: initUI

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
protected void initUI() {
    final AppBarLayout appbarMovieTopChild = (AppBarLayout) findViewById(R.id.appbar_movie_top_child);
    ivBaseTitlebarBg = (ImageView) findViewById(R.id.img_item_bg);
    ivOnePhoto = (ImageView) findViewById(R.id.iv_one_photo);
    tvOneRatingRate = (TextView) findViewById(R.id.tv_one_rating_rate);
    tvOneRatingNumber = (TextView) findViewById(R.id.tv_one_rating_number);
    tvOneGenres = (TextView) findViewById(R.id.tv_one_genres);
    tvOneDay = (TextView) findViewById(R.id.tv_one_day);
    tvOneCity = (TextView) findViewById(R.id.tv_one_city);
    tvFormerly = (TextView) findViewById(R.id.tv_formerly);
    toolbarDoubanDetail = (Toolbar) findViewById(R.id.toolbar_douban_detail);
    initToolBar(toolbarDoubanDetail, "");
    appbarMovieTopChild.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (appbarMovieTopChild.getBottom() > toolbarDoubanDetail.getBottom() ) {
                toolbarDoubanDetail.setBackgroundColor(getResources().getColor(R.color.translucent));
            } else {
                toolbarDoubanDetail.setBackgroundResource(R.color.colorTheme);
            }
        }
    });
    subjectsBean = (HotMovieBean.SubjectsBean) getIntent().getSerializableExtra("bean");
    if (subjectsBean != null) {
        toolbarDoubanDetail.setTitle(subjectsBean.getTitle());
        toolbarDoubanDetail.setSubtitleTextColor(Color.WHITE);
        setImgHeaderBg(subjectsBean.getImages().getMedium());
        GlideUtils.loadMovieTopImg(ivOnePhoto, subjectsBean.getImages().getLarge());
        tvOneRatingRate.setText("评分:" + subjectsBean.getRating().getAverage());
        tvOneGenres.setText("类型:" + StringFormatUtil.formatGenres(subjectsBean.getGenres()));
        tvOneDay.setText("上映日期:" + subjectsBean.getYear());
        //电影详情的id
        id = subjectsBean.getId();
    }

}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:38,代码来源:MovieTopDetailActivity.java

示例10: initView

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
private void initView() {
    layout_appbar = (AppBarLayout) findViewById(R.id.layout_appbar);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    mNick = (TextView) findViewById(R.id.tv_nick);
    iv_logo_head = (ImageView) findViewById(R.id.iv_logo_head);
    tv_logo_nick = (TextView) findViewById(R.id.tv_logo_nick);
    view_divider = findViewById(R.id.view_divider);
    mTabLayout = (TabLayout) findViewById(R.id.layout_tab);
    view_pager = (ViewPager) findViewById(R.id.view_pager);

    toolbar.setTitle("");
    toolbar.setSubtitle("");
    toolbar.setNavigationIcon(R.mipmap.btn_back_normal);
    setSupportActionBar(toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    layout_appbar.addOnOffsetChangedListener(mOffsetChangerListener);

    tv_logo_nick.setText("Limitless");
    iv_logo_head.setImageResource(R.mipmap.ic_launcher);

    mOffsetChangerListener.resetRange();

    requestData();
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:30,代码来源:OtherUserHomeActivity.java

示例11: onCreate

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing_toolbar_layout);
    mIvPlaceholder = (ImageView) findViewById(R.id.main_iv_placeholder);
    mLlTitleContainer = (LinearLayout) findViewById(R.id.main_ll_title_container);
    mFlTitleContainer = (FrameLayout) findViewById(R.id.main_fl_title);
    mAblAppBar = (AppBarLayout) findViewById(R.id.main_abl_app_bar);
    mTvToolbarTitle = (TextView) findViewById(R.id.main_tv_toolbar_title);
    mTbToolbar = (Toolbar) findViewById(R.id.main_tb_toolbar);
    mTbToolbar.setTitle("");

    // AppBar的监听
    mAblAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            int maxScroll = appBarLayout.getTotalScrollRange();
            float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll;
            handleAlphaOnTitle(percentage);
            handleToolbarTitleVisibility(percentage);
        }
    });

    findViewById(R.id.small_photo).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(CollapsingToolbarLayoutActivity.this, SettingsActivity.class));
        }
    });

    initParallaxValues(); // 自动滑动效果
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:33,代码来源:CollapsingToolbarLayoutActivity.java

示例12: onCreate

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //DemoApplication.setMainActivity(this);

    imageUrl = setImageUrl();  //獲取圖片url
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.main_collapsingToolbar);
    collapsingToolbar.setExpandedTitleColor(ContextCompat.getColor(MainActivity.this,R.color.colorAccent));  //設置toolbar背景色
    setSupportActionBar(toolbar);  //設置ActionBar

    mDrawerLayout = (DrawerLayout) findViewById(R.id.dl_menu);
    nvMenu = (NavigationView) findViewById(R.id.nv_menu);
    nvHeardImage = (ImageView) nvMenu.getHeaderView(0).findViewById(R.id.nv_heard_image);
    nvMenu.setNavigationItemSelectedListener(this);
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);
    appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    appBarLayout.addOnOffsetChangedListener(this);
    animationPageCardview = (CardView) findViewById(R.id.animation_pageCard);
    comicPageCardview = (CardView) findViewById(R.id.comic_pageCard);
    mainactivityToolbarImageview = (ImageView) findViewById(R.id.animation_toobarImage);
    setToolbarImage();  //設置ToolBarImage
    setAnimationTitle();  //設置Title
    setNvHeardImage();   //设置NavigationView的heard图片
    setToolBarNavigation();

    animationFragment = new AnimationFragment();  //設置AnimationFragment
    comicFragment = new ComicFragment();  //設置comicFragment
    animationPageSet(animationFragment);  //初始化為animationFragment

    isInternetOk();  //判斷網絡是否打開
    setPayAuthor();
    animationPageCardview.setOnClickListener(this);

    comicPageCardview.setOnClickListener(this);

    swipeRefreshLayout.setOnRefreshListener(this);

    floatingActionButton = (FloatingActionButton) findViewById(R.id.animation_search);

    floatingActionButton.setOnClickListener(this);

}
 
开发者ID:NicoLiutong,项目名称:miaosou,代码行数:46,代码来源:MainActivity.java

示例13: onServiceConnected

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
@Override
public void onServiceConnected(ComponentName className,
                               IBinder service) {
    // We've bound to LocalService, cast the IBinder and get LocalService instance
    binder = (MainService.LocalBinder) service;
    mainService = binder.getService();
    locBound = true;

    Network net = mainService.getNetwork(networkId);
    Line line = net.getLine(lineId);

    String title = String.format(getString(R.string.act_line_title), line.getName());
    setTitle(title);
    getSupportActionBar().setTitle(title);
    AppBarLayout abl = (AppBarLayout) findViewById(R.id.app_bar);
    final CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    ctl.setTitle(title);

    int color = line.getColor();
    ctl.setContentScrimColor(color);
    ctl.setStatusBarScrimColor(color);
    abl.setBackgroundColor(color);

    Drawable drawable = ContextCompat.getDrawable(LineActivity.this, Util.getDrawableResourceIdForLineId(line.getId()));
    drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);

    int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
    FrameLayout iconFrame = new FrameLayout(LineActivity.this);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(height, height);
    int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        params.setMarginEnd(margin);
    }
    params.setMargins(0, 0, margin, 0);
    iconFrame.setLayoutParams(params);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        iconFrame.setBackgroundDrawable(drawable);
    } else {
        iconFrame.setBackground(drawable);
    }
    lineIconsLayout.addView(iconFrame);

    abl.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (ctl.getHeight() + verticalOffset < 2.5 * ViewCompat.getMinimumHeight(ctl)) {
                lineIconsLayout.animate().alpha(0);
            } else {
                lineIconsLayout.animate().alpha(1);
            }
        }
    });

    Map<String, LineStatusCache.Status> statuses = mainService.getLineStatusCache().getLineStatus();
    if (statuses.get(line.getId()) != null &&
            statuses.get(line.getId()).down) {
        disturbancesWarningLayout.setVisibility(View.VISIBLE);
    } else {
        disturbancesWarningLayout.setVisibility(View.GONE);
    }

    LinearLayout closedLayout = (LinearLayout) findViewById(R.id.closed_info_layout);
    if (line.isExceptionallyClosed(new Date())) {
        TextView closedView = (TextView) findViewById(R.id.closed_info_view);
        Formatter f = new Formatter();
        DateUtils.formatDateRange(LineActivity.this, f, line.getNextOpenTime(), line.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
        closedView.setText(String.format(getString(R.string.act_line_closed_schedule), f.toString()));


        closedLayout.setVisibility(View.VISIBLE);
    } else {
        closedLayout.setVisibility(View.GONE);
    }

    populateLineView(LineActivity.this, getLayoutInflater(), net, line, lineLayout);
}
 
开发者ID:gbl08ma,项目名称:underlx,代码行数:77,代码来源:LineActivity.java

示例14: HandleProfileViewBehavior

import android.support.design.widget.AppBarLayout; //导入方法依赖的package包/类
HandleProfileViewBehavior(View rootView) {

        AppBarLayout appbar = (AppBarLayout) rootView.findViewById(R.id.appbar);
        linearLayoutTitle = (LinearLayout) rootView.findViewById(R.id.llTitle);
        textViewTitle = (TextView) rootView.findViewById(R.id.tvToolbarTitle);

        appbar.addOnOffsetChangedListener(this);

        startAlphaAnimation(textViewTitle, 0, View.INVISIBLE);
    }
 
开发者ID:FarshidABZ,项目名称:CoordinatorBehavior,代码行数:11,代码来源:HandleProfileViewBehavior.java


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