您的位置:首页 > 其它

BottomSheetDialogFragment 的使用

2017-08-03 11:16 357 查看

参考文档

https://material.io/guidelines/components/bottom-sheets.html

自定义类:XBottomSheetDialogFragment

public class XBottomSheetDialogFragment extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(R.layout.view_bottom_sheet_fragment, container);
return inflate;
}

}


自定义布局文件 view_bottom_sheet_fragment

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/default_app_main_color">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="300px">
<TextView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="啦啦啦啦啦"/>
</RelativeLayout>

</LinearLayout>


代码中控制显示隐藏

private XBottomSheetDialogFragment mXBottomSheetDialogFragment;

@OnClick(R.id.btn_dialog_fragment)
public void dialog(){
if(mXBottomSheetDialogFragment == null){
mXBottomSheetDialogFragment = new XBottomSheetDialogFragment();
}
mXBottomSheetDialogFragment.show(getSupportFragmentManager(),"Dialog");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  BottomShee