本文整理了Java中com.google.android.material.appbar.AppBarLayout.setLayoutParams()
方法的一些代码示例,展示了AppBarLayout.setLayoutParams()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppBarLayout.setLayoutParams()
方法的具体详情如下:
包路径:com.google.android.material.appbar.AppBarLayout
类名称:AppBarLayout
方法名:setLayoutParams
暂无
代码示例来源:origin: MCMrARM/revolution-irc
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (mCustomContentViewId != 0)
setContentView(mCustomContentViewId);
else
setContentView(R.layout.activity_setup_big_header);
AppBarLayout appBar = findViewById(R.id.appbar);
CollapsingToolbarLayout toolbarLayout = findViewById(R.id.toolbar_layout);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mLayout = findViewById(R.id.layout);
mLayout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
int height = mLayout.getHeight();
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams)
appBar.getLayoutParams();
params.height = height / 3;
appBar.setLayoutParams(params);
int childHeight = (mContentView != null ? mContentView.getHeight() : 0);
if (mContentView instanceof NestedScrollView)
childHeight = ((NestedScrollView) mContentView).getChildAt(0).getHeight();
boolean needsScroll = (mContentView != null && childHeight > height - params.height);
AppBarLayout.LayoutParams paramsToolbar = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams();
paramsToolbar.setScrollFlags(needsScroll
? (AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED)
: 0);
toolbarLayout.setLayoutParams(paramsToolbar);
});
}
代码示例来源:origin: LineageOS/android_packages_apps_Jelly
mAppBar.setLayoutParams(appBarParams);
mAppBar.invalidate();
mWebViewContainer.setLayoutParams(containerParams);
内容来源于网络,如有侵权,请联系作者删除!