Java Code Examples for android.support.design.widget.AppBarLayout#LayoutParams
The following examples show how to use
android.support.design.widget.AppBarLayout#LayoutParams .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollFlag.java From smooth-app-bar-layout with Apache License 2.0 | 6 votes |
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; } } } } }
Example 2
Source File: MainActivity.java From Anecdote with Apache License 2.0 | 6 votes |
private void goToWebsite(Website website) { changeAnecdoteFragment(website, website.pages.get(0)); // We redisplay the toolbar if it was scrollUp by removing the scrollFlags, // wait a litle and reset the last scrollFlags on it (doing it right after was not working final AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) mToolbar.getLayoutParams(); final int scrollFlags = layoutParams.getScrollFlags(); layoutParams.setScrollFlags(0); new Handler().postDelayed(new Runnable() { @Override public void run() { layoutParams.setScrollFlags(scrollFlags); mToolbar.setLayoutParams(layoutParams); } }, 100); }
Example 3
Source File: PaginationHelper.java From ForPDA with GNU General Public License v3.0 | 6 votes |
public void addInToolbar(LayoutInflater inflater, CollapsingToolbarLayout target, boolean enablePadding) { TabLayout tabLayout = (TabLayout) inflater.inflate(R.layout.pagination_toolbar, target, false); target.addView(tabLayout, target.indexOfChild(target.findViewById(R.id.toolbar))); tabLayoutInToolbar = tabLayout; if (enablePadding) { App.get().addStatusBarSizeObserver(statusBarSizeObserver); } AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) target.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); target.setLayoutParams(params); target.setScrimVisibleHeightTrigger(App.px56 + App.px24); setupTabLayout(tabLayout, true); tabLayouts.add(tabLayout); target.requestLayout(); }
Example 4
Source File: NewsDetailsFragment.java From ForPDA with GNU General Public License v3.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); baseInflateFragment(inflater, R.layout.fragment_article); ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content); viewStub.setLayoutResource(R.layout.toolbar_news_details); viewStub.inflate(); fragmentsPager = (ViewPager) findViewById(R.id.view_pager); webViewContainer = (FrameLayout) findViewById(R.id.swipe_refresh_list); progressBar = (ProgressBar) findViewById(R.id.progress_bar); detailsImage = (ImageView) findViewById(R.id.article_image); detailsTitle = (TextView) findViewById(R.id.article_title); detailsNick = (TextView) findViewById(R.id.article_nick); detailsCount = (TextView) findViewById(R.id.article_comments_count); detailsDate = (TextView) findViewById(R.id.article_date); imageProgressBar = (ProgressBar) findViewById(R.id.article_progress_bar); detailsImage.setMaxHeight(App.px24 * 10); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED); toolbarLayout.setLayoutParams(params); return view; }
Example 5
Source File: ProfileFragment.java From ForPDA with GNU General Public License v3.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); baseInflateFragment(inflater, R.layout.fragment_profile); ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content); viewStub.setLayoutResource(R.layout.toolbar_profile); viewStub.inflate(); nick = (TextView) findViewById(R.id.profile_nick); group = (TextView) findViewById(R.id.profile_group); sign = (TextView) findViewById(R.id.profile_sign); avatar = (ImageView) findViewById(R.id.profile_avatar); recyclerView = (RecyclerView) findViewById(R.id.profile_list); progressView = (CircularProgressView) findViewById(R.id.profile_progress); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED); toolbarLayout.setLayoutParams(params); return view; }
Example 6
Source File: VideoDetailActivity.java From LQRBiliBlili with MIT License | 6 votes |
private void showVideoStartTip() { mRlVideoTip.setVisibility(View.VISIBLE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Animator circularReveal = ViewAnimationUtils.createCircularReveal(mRlVideoTip, mIvCover.getWidth() - ArmsUtils.dip2px(VideoDetailActivity.this, mAnchorX), mIvCover.getHeight() - ArmsUtils.dip2px(VideoDetailActivity.this, mAnchorY), 0, ((float) Math.hypot(mIvCover.getWidth(), mIvCover.getHeight()))); circularReveal.setDuration(800); circularReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mIvCover.setVisibility(View.GONE); mPresenter.loadPlayUrl(aid); } }); circularReveal.start(); } else { mPresenter.loadPlayUrl(aid); } // 锁定AppBarLayout AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) mAppbar.getChildAt(0).getLayoutParams(); layoutParams.setScrollFlags(0); mAppbar.getChildAt(0).setLayoutParams(layoutParams); }
Example 7
Source File: ActivityMain.java From fingen with Apache License 2.0 | 6 votes |
@Override public void onResume() { super.onResume(); Log.d(TAG, "MainActivity onResume"); mLastBackPressed = -1; NotificationHelper.getInstance(this).cancel(SMSReceiver.NOTIFICATION_ID_TRANSACTION_AUTO_CREATED); NotificationCounter notificationCounter = new NotificationCounter(mPreferences); notificationCounter.removeNotification(SMSReceiver.NOTIFICATION_ID_TRANSACTION_AUTO_CREATED); mMaterialDrawer.deselect(); updateCounters(); // updateLists(); if (mPreferences.getBoolean(FgConst.PREF_HIDE_SUMS_PANEL, true)) { AppBarLayout.LayoutParams paramsABL = (AppBarLayout.LayoutParams) toolbar.getLayoutParams(); paramsABL.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP); toolbar.requestLayout(); } }
Example 8
Source File: ScrollFlag.java From Expert-Android-Programming with MIT License | 6 votes |
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; } } } } }
Example 9
Source File: ToolBarUtil.java From Android-Architecture with Apache License 2.0 | 5 votes |
/** * 向上需要全部滚出屏幕时设置topMargin代替fitsSystemWindows="true" * * @param toolbar */ public static void setStatusBarFits(Toolbar toolbar) { if (toolbar == null) return; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (toolbar.getLayoutParams() instanceof AppBarLayout.LayoutParams) { AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams(); params.topMargin = StatusBarUtil.getStatusBarHeight(toolbar.getContext()); toolbar.setLayoutParams(params); hideNavigationBar((Activity) toolbar.getContext()); } } }
Example 10
Source File: DeviceFragment.java From ForPDA with GNU General Public License v3.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); baseInflateFragment(inflater, R.layout.fragment_device); ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content); viewStub.setLayoutResource(R.layout.toolbar_device); toolbarContent = (RelativeLayout) viewStub.inflate(); imagesPager = (PagerBullet) findViewById(R.id.images_pager); progressBar = (ProgressBar) findViewById(R.id.progress_bar); rating = (TextView) findViewById(R.id.item_rating); fragmentsPager = (ViewPager) findViewById(R.id.view_pager); tabLayout = new TabLayout(getContext()); CollapsingToolbarLayout.LayoutParams tabParams = new CollapsingToolbarLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM); tabParams.setCollapseMode(CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PIN); tabLayout.setLayoutParams(tabParams); toolbarLayout.addView(tabLayout); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED); toolbarLayout.setLayoutParams(params); CollapsingToolbarLayout.LayoutParams newParams = (CollapsingToolbarLayout.LayoutParams) toolbar.getLayoutParams(); newParams.setCollapseMode(CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PIN); newParams.bottomMargin = App.px48; toolbar.setLayoutParams(newParams); toolbar.requestLayout(); return view; }
Example 11
Source File: BaseActivity.java From OpenHub with GNU General Public License v3.0 | 5 votes |
protected void setToolbarScrollAble(boolean scrollAble) { if(toolbar == null) return; int flags = scrollAble ? (AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS | AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP) : 0; AppBarLayout.LayoutParams layoutParams = (AppBarLayout.LayoutParams) toolbar.getLayoutParams(); layoutParams.setScrollFlags(flags); toolbar.setLayoutParams(layoutParams); }
Example 12
Source File: GankIoDetailActivity.java From YiZhi with Apache License 2.0 | 5 votes |
@Override protected void initView(Bundle savedInstanceState) { super.initView(savedInstanceState); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) appBar.getChildAt(0) .getLayoutParams(); // 控件的高强制设成56dp+状态栏高度,重新定义AppBarLayout的高度 params.height = DisplayUtils.dp2px(56) + StatusBarUtils.getStatusBarHeight (mContext); }
Example 13
Source File: WebViewLoadActivity.java From YiZhi with Apache License 2.0 | 5 votes |
@Override protected void initView(Bundle savedInstanceState) { super.initView(savedInstanceState); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) appBar.getChildAt(0) .getLayoutParams(); // 控件的高强制设成56dp+状态栏高度 params.height = DisplayUtils.dp2px(56) + StatusBarUtils.getStatusBarHeight (mContext); }
Example 14
Source File: WeixinChoiceDetailActivity.java From YiZhi with Apache License 2.0 | 5 votes |
@Override protected void initView(Bundle savedInstanceState) { super.initView(savedInstanceState); //微信精选内部已经有Title等信息,直接显示webview内容 //tvDetailTitle.setText(mTitle); //tvDetailcopyright.setText(mCopyright); //Glide.with(mContext).load(mImageUrl).crossFade().into(ivDetail); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) appBar.getChildAt(0) .getLayoutParams(); // 控件的高强制设成56dp+状态栏高度 params.height = DisplayUtils.dp2px(56) + StatusBarUtils.getStatusBarHeight (mContext); }
Example 15
Source File: CollapsingToolbarLayoutManager.java From react-native-collapsing-toolbar with MIT License | 5 votes |
@ReactProp(name = "scrollFlags") public void setExpandedTitleGravity(CollapsingToolbarLayoutView view, int flags) { AppBarLayout.LayoutParams params = new AppBarLayout.LayoutParams( AppBarLayout.LayoutParams.MATCH_PARENT, AppBarLayout.LayoutParams.MATCH_PARENT ); params.setScrollFlags(flags); view.setLayoutParams(params); }
Example 16
Source File: CollapsingToolbarLayoutView.java From react-native-collapsing-toolbar with MIT License | 5 votes |
public CollapsingToolbarLayoutView(Context context) { super(context); int width = AppBarLayout.LayoutParams.MATCH_PARENT; int height = AppBarLayout.LayoutParams.MATCH_PARENT; AppBarLayout.LayoutParams params = new AppBarLayout.LayoutParams(width, height); this.setScrimsShown(false, true); this.setLayoutParams(params); this.setFitsSystemWindows(true); }
Example 17
Source File: MainActivity.java From Anecdote with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { Scope scope = Toothpick.openScopes(getApplication(), this); super.onCreate(savedInstanceState); Toothpick.inject(this, scope); if (EventTracker.isEventEnable()) { new EventTracker(this); } setContentView(R.layout.activity_main); ButterKnife.bind(this); setSupportActionBar(mToolbar); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); mDrawerLayout.addDrawerListener(toggle); toggle.syncState(); mNavigationView.setNavigationItemSelectedListener(this); // Process migration before getting anything else from shared preferences boolean openWebsiteChooserAddMode = SpStorage.migrate(this); mWebsites = SpStorage.getWebsites(this); mServiceProvider.createAnecdoteService(this, mWebsites); mServiceProvider.register(EventBus.getDefault()); populateNavigationView(false); mNetworkConnectivityListener = new NetworkConnectivityListener(); mNetworkConnectivityListener.startListening(this, this); AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) mToolbar.getLayoutParams(); mToolbarScrollFlags = params.getScrollFlags(); mFragmentStackManager = new FragmentStackManager(mSnackbar); if (openWebsiteChooserAddMode) { changeFragment(WebsiteChooserFragment.newInstance(WebsiteChooserFragment.BUNDLE_MODE_ADD), false, false); } else if (SpStorage.isFirstLaunch(this) || mWebsites.isEmpty()) { changeFragment(Fragment.instantiate(this, WebsiteChooserFragment.class.getName()), false, false); } else { changeAnecdoteFragment(mWebsites.get(0), mWebsites.get(0).pages.get(0)); } mToolbarSpinnerAdapter = new ToolbarSpinnerAdapter(getApplicationContext(), "test", new ArrayList<String>()); mToolbarSpinner.setAdapter(mToolbarSpinnerAdapter); }
Example 18
Source File: NavigationViewItemSelectedListener.java From openwebnet-android with MIT License | 4 votes |
private void toggleScrollActionBar() { AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); }
Example 19
Source File: NavigationViewItemSelectedListener.java From openwebnet-android with MIT License | 4 votes |
private void disableScrollActionBar() { AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbar.getLayoutParams(); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP); }
Example 20
Source File: AppBarLayoutView.java From react-native-collapsing-toolbar with MIT License | 3 votes |
public AppBarLayoutView(Context context) { super(context); int width = ViewGroup.LayoutParams.MATCH_PARENT; int height = ViewGroup.LayoutParams.WRAP_CONTENT; AppBarLayout.LayoutParams params = new AppBarLayout.LayoutParams(width, height); this.setLayoutParams(params); }