本文整理了Java中android.support.v7.widget.Toolbar.getPaddingTop()
方法的一些代码示例,展示了Toolbar.getPaddingTop()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Toolbar.getPaddingTop()
方法的具体详情如下:
包路径:android.support.v7.widget.Toolbar
类名称:Toolbar
方法名:getPaddingTop
暂无
代码示例来源:origin: florent37/MaterialViewPager
@Override
public boolean onPreDraw() {
//rotation fix, if not set, originalTitleY = Na
ViewCompat.setTranslationY(mLogo,0);
ViewCompat.setTranslationX(mLogo, 0);
originalTitleY = ViewCompat.getY(mLogo);
originalTitleX = ViewCompat.getX(mLogo);
originalTitleHeight = mLogo.getHeight();
finalTitleHeight = dpToPx(21, context);
//the final scale of the logo
finalScale = finalTitleHeight / originalTitleHeight;
finalTitleY = (toolbar.getPaddingTop() + toolbar.getHeight()) / 2 - finalTitleHeight / 2 - (1 - finalScale) * finalTitleHeight;
//(mLogo.getWidth()/2) *(1-finalScale) is the margin left added by the scale() on the logo
//when logo scaledown, the content stay in center, so we have to anually remove the left padding
finalTitleX = dpToPx(52f, context) - (mLogo.getWidth() / 2) * (1 - finalScale);
toolbarLayout.getViewTreeObserver().removeOnPreDrawListener(this);
return false;
}
});
代码示例来源:origin: chaychan/TouTiao
lp.height += statusBarHeight;
toolbar.setLayoutParams(lp);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
toolbar.setTag(true);
代码示例来源:origin: chaychan/TouTiao
lp.height += statusBarHeight;
toolbar.setLayoutParams(lp);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
toolbar.setTag(true);
代码示例来源:origin: chaychan/TouTiao
lp.height += statusBarHeight;
toolbar.setLayoutParams(lp);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
toolbar.setTag(true);
代码示例来源:origin: chaychan/TouTiao
lp.height += statusBarHeight;
toolbar.setLayoutParams(lp);
toolbar.setPadding(toolbar.getPaddingLeft(), toolbar.getPaddingTop() + statusBarHeight, toolbar.getPaddingRight(), toolbar.getPaddingBottom());
toolbar.setTag(true);
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void run() {
statusBarOverlay.setBounds(new Rect(0, 0,
toolbar.getWidth(), toolbar.getPaddingTop()));
toolbar.getOverlay().add(statusBarOverlay);
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onGlobalLayout() {
toolbar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
// hacky way of getting window insets on pre-Lollipop
// somewhat works...
int[] screenSize = Util.getScreenSize(SetWallpaperActivity.this);
int[] windowInsets = new int[]{
Math.abs(screenSize[0] - toolbar.getLeft()),
Math.abs(screenSize[1] - toolbar.getTop()),
Math.abs(screenSize[2] - toolbar.getRight()),
Math.abs(0)};
toolbar.setPadding(toolbar.getPaddingStart() + windowInsets[0],
toolbar.getPaddingTop() + windowInsets[1],
toolbar.getPaddingEnd() + windowInsets[2],
toolbar.getPaddingBottom());
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onGlobalLayout() {
//hacky way of getting window insets on pre-Lollipop
int[] screenSize = Util.getScreenSize(ExifEditorActivity.this);
int[] windowInsets = new int[]{
Math.abs(screenSize[0] - rootView.getLeft()),
Math.abs(screenSize[1] - rootView.getTop()),
Math.abs(screenSize[2] - rootView.getRight()),
Math.abs(screenSize[3] - rootView.getBottom())};
toolbar.setPadding(toolbar.getPaddingStart() + windowInsets[0],
toolbar.getPaddingTop() + windowInsets[1],
toolbar.getPaddingEnd() + windowInsets[2],
toolbar.getPaddingBottom());
recyclerView.setPadding(recyclerView.getPaddingStart() + windowInsets[0],
recyclerView.getPaddingTop(),
recyclerView.getPaddingEnd() + windowInsets[2],
recyclerView.getPaddingBottom() + windowInsets[3]);
rootView.getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onSwipeProcess(float percent) {
getWindow().getDecorView().setBackgroundColor(
SwipeBackCoordinatorLayout.getBackgroundColor(percent));
boolean selectorModeActive = ((FileExplorerAdapter) recyclerView.getAdapter()).isModeActive();
if (!theme.darkStatusBarIcons() && selectorModeActive) {
SwipeBackCoordinatorLayout layout = findViewById(R.id.swipeBackView);
Toolbar toolbar = findViewById(R.id.toolbar);
View rootView = findViewById(R.id.root_view);
int translationY = (int) layout.getTranslationY();
int statusBarHeight = toolbar.getPaddingTop();
if (translationY > statusBarHeight * 0.5) {
Util.setLightStatusBarIcons(rootView);
} else {
Util.setDarkStatusBarIcons(rootView);
}
}
}
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onGlobalLayout() {
//hacky way of getting window insets on pre-Lollipop
int[] screenSize = Util.getScreenSize(VirtualAlbumsActivity.this);
int[] windowInsets = new int[]{
Math.abs(screenSize[0] - rootView.getLeft()),
Math.abs(screenSize[1] - rootView.getTop()),
Math.abs(screenSize[2] - rootView.getRight()),
Math.abs(screenSize[3] - rootView.getBottom())};
toolbar.setPadding(toolbar.getPaddingStart() + windowInsets[0],
toolbar.getPaddingTop() + windowInsets[1],
toolbar.getPaddingEnd() + windowInsets[2],
toolbar.getPaddingBottom());
recyclerView.setPadding(recyclerView.getPaddingStart() + windowInsets[0],
recyclerView.getPaddingTop(),
recyclerView.getPaddingEnd() + windowInsets[2],
recyclerView.getPaddingBottom() + windowInsets[3]);
rootView.getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onScrollChange(NestedScrollView nestedScrollView, int scrollX, int scrollY,
int oldScrollX, int oldScrollY) {
int statusBarHeight = toolbar.getPaddingTop();
if (scrollY > header.getHeight() - statusBarHeight / 2) {
if (theme.darkStatusBarIcons()) {
Util.setDarkStatusBarIcons(rootView);
} else {
Util.setLightStatusBarIcons(rootView);
}
} else {
if (theme.darkStatusBarIconsInSelectorMode()) {
Util.setDarkStatusBarIcons(rootView);
} else {
Util.setLightStatusBarIcons(rootView);
}
}
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onSwipeProcess(float percent) {
getWindow().getDecorView().setBackgroundColor(SwipeBackCoordinatorLayout.getBackgroundColor(percent));
SwipeBackCoordinatorLayout layout = findViewById(R.id.swipeBackView);
Toolbar toolbar = findViewById(R.id.toolbar);
View rootView = findViewById(R.id.root_view);
int translationY = (int) layout.getTranslationY();
int statusBarHeight = toolbar.getPaddingTop();
if (translationY > statusBarHeight * 0.5) {
if (theme.darkStatusBarIcons()) {
Util.setDarkStatusBarIcons(rootView);
} else {
Util.setLightStatusBarIcons(rootView);
}
}
}
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
// clear this listener so insets aren't re-applied
toolbar.setOnApplyWindowInsetsListener(null);
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
toolbar.getPaddingBottom());
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
public void onSwipeProcess(float percent) {
getWindow().getDecorView().setBackgroundColor(
SwipeBackCoordinatorLayout.getBackgroundColor(percent));
boolean selectorModeActive = recyclerViewAdapter.isSelectorModeActive();
if (!theme.darkStatusBarIcons() && selectorModeActive) {
SwipeBackCoordinatorLayout layout = findViewById(R.id.swipeBackView);
Toolbar toolbar = findViewById(R.id.toolbar);
View rootView = findViewById(R.id.root_view);
int translationY = (int) layout.getTranslationY();
int statusBarHeight = toolbar.getPaddingTop();
if (translationY > statusBarHeight * 0.5) {
Util.setLightStatusBarIcons(rootView);
} else {
Util.setDarkStatusBarIcons(rootView);
}
}
}
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
toolbar.getPaddingBottom());
recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(),
recyclerView.getPaddingTop(),
recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(),
recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
toolbar.getPaddingBottom());
recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(),
recyclerView.getPaddingTop(),
recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(),
recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
toolbar.getPaddingBottom());
bottomBar.setPadding(bottomBar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
bottomBar.getPaddingTop(),
bottomBar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
bottomBar.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
toolbar.getPaddingBottom());
recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(),
recyclerView.getPaddingTop(),
recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(),
recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart() /*+ insets.getSystemWindowInsetLeft()*/,
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() /*+ insets.getSystemWindowInsetRight()*/,
toolbar.getPaddingBottom());
ViewGroup.MarginLayoutParams toolbarParams
= (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
toolbarParams.leftMargin += insets.getSystemWindowInsetLeft();
toolbarParams.rightMargin += insets.getSystemWindowInsetRight();
toolbar.setLayoutParams(toolbarParams);
container.setPadding(container.getPaddingStart() + insets.getSystemWindowInsetLeft(),
container.getPaddingTop(),
container.getPaddingEnd() + insets.getSystemWindowInsetRight(),
container.getPaddingBottom() + insets.getSystemWindowInsetBottom());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(),
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(),
toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(),
toolbar.getPaddingBottom());
actionArea.setPadding(actionArea.getPaddingStart() + insets.getSystemWindowInsetLeft(),
actionArea.getPaddingTop(),
actionArea.getPaddingEnd() + insets.getSystemWindowInsetRight(),
actionArea.getPaddingBottom() + insets.getSystemWindowInsetBottom());
imageView.setPadding(imageView.getPaddingStart() + insets.getSystemWindowInsetLeft(),
imageView.getPaddingTop()/* + insets.getSystemWindowInsetTop()*/,
imageView.getPaddingEnd() + insets.getSystemWindowInsetRight(),
imageView.getPaddingBottom()/* + insets.getSystemWindowInsetBottom()*/);
return insets.consumeSystemWindowInsets();
}
});
内容来源于网络,如有侵权,请联系作者删除!