use of com.shiqkuangsan.mycustomviews.ui.custom.behavior.BottomSheetBehaviorGoogleMapsLike in project CustomViews by AndroidStudy233.
the class CustomBehaviorAct22 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bottomsheet_behavior);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_bottom_behavior);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(" ");
}
/**
* If we want to listen for states callback
*/
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorlayout);
View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);
final BottomSheetBehaviorGoogleMapsLike behavior = BottomSheetBehaviorGoogleMapsLike.from(bottomSheet);
behavior.addBottomSheetCallback(new BottomSheetBehaviorGoogleMapsLike.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch(newState) {
case BottomSheetBehaviorGoogleMapsLike.STATE_COLLAPSED:
Log.d("bottomsheet-", "STATE_COLLAPSED");
break;
case BottomSheetBehaviorGoogleMapsLike.STATE_DRAGGING:
Log.d("bottomsheet-", "STATE_DRAGGING");
break;
case BottomSheetBehaviorGoogleMapsLike.STATE_EXPANDED:
Log.d("bottomsheet-", "STATE_EXPANDED");
break;
case BottomSheetBehaviorGoogleMapsLike.STATE_ANCHOR_POINT:
Log.d("bottomsheet-", "STATE_ANCHOR_POINT");
break;
case BottomSheetBehaviorGoogleMapsLike.STATE_HIDDEN:
Log.d("bottomsheet-", "STATE_HIDDEN");
break;
default:
Log.d("bottomsheet-", "STATE_SETTLING");
break;
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
AppBarLayout mergedAppBarLayout = (AppBarLayout) findViewById(R.id.merged_appbarlayout);
MergedAppBarLayoutBehavior mergedAppBarLayoutBehavior = MergedAppBarLayoutBehavior.from(mergedAppBarLayout);
mergedAppBarLayoutBehavior.setToolbarTitle("Title Dummy");
mergedAppBarLayoutBehavior.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
behavior.setState(BottomSheetBehaviorGoogleMapsLike.STATE_COLLAPSED);
}
});
bottomSheetTextView = (TextView) bottomSheet.findViewById(R.id.bottom_sheet_title);
NormalImagePagerAdapter adapter = new NormalImagePagerAdapter(this, mDrawables);
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(adapter);
behavior.setState(BottomSheetBehaviorGoogleMapsLike.STATE_ANCHOR_POINT);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
return;
Window window = getWindow();
// 清除状态栏半透明
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 状态栏全透明
window.setStatusBarColor(Color.RED);
}
Aggregations