我BottomSheet在android支持中尝试了新功能.在里面BottomSheet我放了一个TextView和一个ScrollView.该BottomSheet表现得很好,我发现的唯一的问题是,ScrollView在BottomSheet没有滚动.每次我尝试滚动时,滚动的主要活动中的布局或BottomSheet从折叠到展开的更改状态.
这是我的Activity类代码的片段:
private BottomSheetBehavior behavior;
View bottomSheet;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setTextViewOnClickListener(this, findViewById(R.id.parentLayout));
CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_content);
// The View with the BottomSheetBehavior
bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);
behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
// React to state change
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// React to …Run Code Online (Sandbox Code Playgroud)