从版本23.4.0切换到Android设计支持库的版本24.2.1后,BottomSheetBehavior停止工作。底部表格显示为打开并在致电setState(BottomSheetBehavior.STATE_COLLAPSED)
时不关闭。这不会发生在BottomSheetBehaviour按预期工作的设计库的23.4.0版本中。Android设计支持库24.2.1使BottomSheet在启动时打开
版本24中是否有任何更改需要使用BottomSheetBehavior的不同?
这是我的布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="Open Bottom Sheet"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/close_button"
android:text="Close Bottom Sheet"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
android:background="@android:color/holo_green_light"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"/>
这里是我使用的活动代码:
public class ScrollingActivity extends AppCompatActivity implements View.OnClickListener {
private View m_bottomSheet;
private BottomSheetBehavior m_behaviour;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
m_bottomSheet = findViewById(R.id.bottom_sheet);
m_behaviour = BottomSheetBehavior.from(m_bottomSheet);
((Button)findViewById(R.id.button)).setOnClickListener(this);
((Button)findViewById(R.id.close_button)).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.button:
m_behaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
break;
case R.id.close_button:
m_behaviour.setState(BottomSheetBehavior.STATE_COLLAPSED);
break;
}
}
}
任何意见,将不胜感激。
http://stackoverflow.com/questions/39030742/bottomsheetbehavior-is-not-work-when-design-library-update-to-24-2 -0 –