我是这样使用Android支持库中的Bottom Sheet:
XML:
<LinearLayout
android:id="@+id/bottomSheetLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/fourth_white"
android:orientation="vertical"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior" />
我将子视图添加到LinearLayout中:
bottomSheet.addView(actionButtonView);
在我添加完子视图之后,我初始化BottomSheetBehavior并展开它:
BottomSheetBehavior sheetBehavior = BottomSheetBehavior.from(bottomSheet);
sheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
这不起作用。什么都没有显示。即使我在XML中预设LinearLayout的高度,它也只是全白。
如果我在XML中添加所有子视图到LinearLayout中,那么一切都正常工作。但是当我尝试以编程方式动态添加视图时,它就不起作用。
有人遇到过类似的问题吗?
actionButtonView
的吗? - himanshu1496