本文整理汇总了Java中android.support.design.widget.AppBarLayout类的典型用法代码示例。如果您正苦于以下问题:Java AppBarLayout类的具体用法?Java AppBarLayout怎么用?Java AppBarLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppBarLayout类属于android.support.design.widget包,在下文中一共展示了AppBarLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED, verticalOffset);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED, verticalOffset);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE, verticalOffset);
}
mCurrentState = State.IDLE;
}
}
示例2: setOffsetValue
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
/**
* Define one of the point in where the FAB should be hide when it reachs that point.
* @param coordinatorLayout container of BottomSheet and AppBarLayout
*/
private void setOffsetValue(CoordinatorLayout coordinatorLayout) {
for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
View child = coordinatorLayout.getChildAt(i);
if (child instanceof AppBarLayout) {
if (child.getTag() != null &&
child.getTag().toString().contentEquals("modal-appbar") ) {
offset = child.getY()+child.getHeight();
break;
}
}
}
}
示例3: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
if (i == 0) {
if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED);
}
mCurrentState = State.EXPANDED;
} else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) {
if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED);
}
mCurrentState = State.COLLAPSED;
} else {
if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE);
}
mCurrentState = State.IDLE;
}
}
示例4: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (!TextUtils.isEmpty(subTitle)) {
float value = appBar.getHeight() - toolbar.getHeight() * 2;
float p = (value + verticalOffset) / value;
if (p < 0) {
p = 0;
}
subtitleView.setPercent(p);
}
// if (Math.abs(verticalOffset) > appBarLayout.getHeight() / 2) {
// int color = getResources().getColor(R.color.colorPrimary);
// titleTextView.setTextColor(color);
// toolbar.getNavigationIcon().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
// } else {
// int white = getResources().getColor(R.color.white);
// toolbar.getNavigationIcon().setColorFilter(white, PorterDuff.Mode.MULTIPLY);
// titleTextView.setTextColor(white);
// }
}
示例5: onCreateView
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.content_notifications, container, false);
AppBarLayout appBarLayout = getActivity().findViewById(R.id.appbar);
if (appBarLayout.getChildCount() == 1) {
mSectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager());
mViewPager = rootView.findViewById(R.id.tab_container);
mViewPager.setAdapter(mSectionsPagerAdapter);
mTabLayout = new TabLayout(getActivity());
mTabLayout.setTabTextColors(
getResources().getColor(R.color.disabledGrey),
getResources().getColor(R.color.white)
);
mTabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
mTabLayout.setupWithViewPager(mViewPager);
appBarLayout.addView(mTabLayout);
}
return rootView;
}
示例6: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
int a = appBarLayout.getTotalScrollRange();
// Log.e("offset", verticalOffset + "----" + a);
if (verticalOffset == 0) {
//expand all
back.setImageResource(R.drawable.back_black);
} else if (Math.abs(verticalOffset) >= a) {
//closed totally
title.setVisibility(View.VISIBLE);
icon.setVisibility(View.VISIBLE);
back.setImageResource(R.drawable.back_white);
} else {
title.setVisibility(View.GONE);
icon.setVisibility(View.GONE);
//doing the transition
}
}
示例7: initToolBar
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
/**
* 初始化toolbar
*/
private void initToolBar(){
mAppBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
//设置导航图标要在setSupportActionBar方法之后
mToolbar=(Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
//这里必须设置一个空标题,不然toolbar中的textview标题不居中
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int menuItemId = item.getItemId();
if (menuItemId == R.id.action_more) {
Toast.makeText(PersonalHomeActivity.this, "举报", Toast.LENGTH_SHORT).show();
}
return true;
}
});
mToolbar.setNavigationIcon(R.drawable.white_back);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
示例8: disableSearchMode
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
private void disableSearchMode() {
if (searchMode) {
searchMode = false;
//display tabs again
AppBarLayout appbar = (AppBarLayout) findViewById(R.id.appbar);
appbar.removeView(tabLayout); //make sure we're not adding the tabLayout while it's already there
appbar.addView(tabLayout);
//display floating button
mFab.setVisibility(View.VISIBLE);
//hide searchbar
mSearchBar.setVisibility(View.GONE);
//refresh the fragment display
mViewPager.setAdapter(null);
mViewPager.setAdapter(mSectionsPagerAdapter);
}
}
示例9: initBar
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
private void initBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
mToolbar.setNavigationIcon(R.mipmap.ic_scan);
mToolbar.setNavigationOnClickListener(v -> SnackBarUtil.show(NormalActivity.this, "哥,别扫了"));
mNavigationIcon = mToolbar.getNavigationIcon();
mAppBar.addOnOffsetChangedListener((AppBarLayout appBarLayout, int verticalOffset) -> {
int totalScrollRange = appBarLayout.getTotalScrollRange();
float percent = Math.abs(verticalOffset * 1.0f / totalScrollRange);
if (mNavigationIcon != null) {
mNavigationIcon.setColorFilter((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK), PorterDuff.Mode.SRC_IN);
}
if (mSearchItemIcon != null) {
mSearchItemIcon.setColorFilter((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK), PorterDuff.Mode.SRC_IN);
}
mTitle.setTextColor((int) mArgbEvaluator.evaluate(percent, Color.WHITE, Color.BLACK));
});
}
示例10: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (Math.abs(verticalOffset) - appBarLayout.getTotalScrollRange() == 0) {
activityTtile.setVisibility(View.VISIBLE);
activityTtile.setText(personName.getText());
toolbar.setBackgroundColor(toolbarColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().setStatusBarColor(Utils.getDarkColor(toolbarColor));
}
} else {
activityTtile.setVisibility(View.GONE);
toolbar.setBackgroundColor(ContextCompat.getColor(activity, android.R.color.transparent));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().setStatusBarColor(ContextCompat.getColor(activity, android.R.color.transparent));
}
}
}
示例11: ScrollFlag
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
public ScrollFlag(AppBarLayout layout) {
if (layout != null) {
int i = 0;
for (int z = layout.getChildCount(); i < z; ++i) {
View child = layout.getChildAt(i);
ViewGroup.LayoutParams layoutParams = child.getLayoutParams();
if (layoutParams instanceof AppBarLayout.LayoutParams) {
AppBarLayout.LayoutParams childLp = (AppBarLayout.LayoutParams) layoutParams;
int flags = childLp.getScrollFlags();
if ((flags & AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL) != 0) {
vView = child;
mFlags = flags;
break;
}
}
}
}
}
示例12: onOffsetChanged
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (mMaxScrollSize == 0)
mMaxScrollSize = appBarLayout.getTotalScrollRange();
int percentage = (Math.abs(verticalOffset)) * 100 / mMaxScrollSize;
if (percentage >= PERCENTAGE_TO_ANIMATE_AVATAR && mIsAvatarShown) {
mIsAvatarShown = false;
imgProfile.animate()
.scaleY(0).scaleX(0)
.setDuration(200)
.start();
}
if (percentage <= PERCENTAGE_TO_ANIMATE_AVATAR && !mIsAvatarShown) {
mIsAvatarShown = true;
imgProfile.animate()
.scaleY(1).scaleX(1)
.start();
}
}
示例13: scale
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
private void scale(AppBarLayout abl, View target, int dy) {
mTotalDy += -dy;
mTotalDy = Math.min(mTotalDy, TARGET_HEIGHT);
mLastScale = Math.max(1f, 1f + mTotalDy / TARGET_HEIGHT);
mTargetView.setScaleX(mLastScale);
mTargetView.setScaleY(mLastScale);
mLastBottom = mParentHeight + (int) (mTargetViewHeight / 2 * (mLastScale - 1));
abl.setBottom(mLastBottom);
target.setScrollY(0);
}
开发者ID:crazysunj,项目名称:MultiTypeRecyclerViewAdapter,代码行数:11,代码来源:AppBarLayoutOverScrollViewBehavior.java
示例14: onCreate
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
setContentView(R.layout.activity_toolbar);
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);
}
});
}
示例15: onCreateView
import android.support.design.widget.AppBarLayout; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
AppBarLayout appBarLayout = getActivity().findViewById(R.id.appbar);
if (appBarLayout.getChildCount() != 1) {
appBarLayout.removeViewAt(1);
}
final View view = inflater.inflate(R.layout.content_today, container, false);
recyclerView = view.findViewById(R.id.recyclingAgenda);
aAdapter = new AgendaAppointmentAdapter(agendaAppointmentSet);
RecyclerView.LayoutManager aLayoutManager = new LinearLayoutManager(view.getContext()) {
@Override
public boolean canScrollVertically() {
return false;
}
};
recyclerView.setLayoutManager(aLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(aAdapter);
return view;
}