下面列出了android.view.ViewGroup#setTranslationY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onBottomSheetChanged(
CoordinatorLayout parent, ViewGroup layout, BottomSheetMetrics metrics) {
ViewGroup toolbarWrapper = layout.findViewById(R.id.toolbar_wrapper);
View bottomSheetScrim = layout.findViewById(R.id.bottom_sheet_bottom_inset_scrim);
View hamburgerButton = parent.findViewById(R.id.hamburger_btn);
View mapScrim = parent.findViewById(R.id.map_scrim);
// Fade in the bottom scrim and "Add Observation" button, with both being fully visible as soon
// as the top of the bottom sheet passes the top of the "Add Observation" button.
float revealRatio = metrics.getRevealRatio();
float hideRatio = 1.0f - revealRatio;
layout.setAlpha(revealRatio);
mapScrim.setAlpha(metrics.getExpansionRatio());
bottomSheetScrim.setAlpha(revealRatio);
toolbarWrapper.setAlpha(revealRatio);
toolbarWrapper.setTranslationY(-toolbarWrapper.getHeight() * hideRatio);
hamburgerButton.setAlpha(hideRatio);
}
private void setupMenu() {
menu = (ViewGroup) findViewById(R.id.menu_container);
int color = getResources().getColor(R.color.splash1);
addMenuItem(menu, "Water And Noise", R.drawable.splash1, color, R.drawable.menu_btn, 0);
addMenuItem(menu, "Two Bears", R.drawable.splash2, getResources().getColor(R.color.splash2), R.drawable.menu_btn2, 1);
addMenuItem(menu, "Depth Playground", R.drawable.splash3, getResources().getColor(R.color.splash3), R.drawable.menu_btn3, 2);
addMenuItem(menu, "About", R.drawable.splash4, getResources().getColor(R.color.splash4), R.drawable.menu_btn4, 3);
selectMenuItem(0, color);
menu.setTranslationY(20000);
}
private void setupMenu() {
menu = (ViewGroup) findViewById(R.id.menu_container);
int color = getResources().getColor(R.color.splash1);
addMenuItem(menu, "Water And Noise", R.drawable.splash1, color, R.drawable.menu_btn, 0);
addMenuItem(menu, "Two Bears", R.drawable.splash2, getResources().getColor(R.color.splash2), R.drawable.menu_btn2, 1);
addMenuItem(menu, "Depth Playground", R.drawable.splash3, getResources().getColor(R.color.splash3), R.drawable.menu_btn3, 2);
addMenuItem(menu, "About", R.drawable.splash4, getResources().getColor(R.color.splash4), R.drawable.menu_btn4, 3);
selectMenuItem(0, color);
menu.setTranslationY(20000);
}
private void setupMenu() {
menu = (ViewGroup) findViewById(R.id.menu_container);
int color = getResources().getColor(R.color.splash1);
addMenuItem(menu, "Water And Noise", R.drawable.splash1, color, R.drawable.menu_btn, 0);
addMenuItem(menu, "Two Bears", R.drawable.splash2, getResources().getColor(R.color.splash2),
R.drawable.menu_btn2, 1);
addMenuItem(menu, "Depth Playground", R.drawable.splash3,
getResources().getColor(R.color.splash3), R.drawable.menu_btn3, 2);
addMenuItem(menu, "About", R.drawable.splash4, getResources().getColor(R.color.splash4),
R.drawable.menu_btn4, 3);
selectMenuItem(0, color);
menu.setTranslationY(20000);
}