本文整理匯總了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());
}
示例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);
}
示例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);
}
}
});
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
示例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(); // 自動滑動效果
}
示例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);
}
示例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);
}
示例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);
}