使用 DialogFragment 和 BottomSheet 实现底部弹出框
2017-09-15 14:21
465 查看
BottomMenuTutorial
项目地址:fccaikai/BottomMenuTutorial简介:使用 DialogFragment 和 BottomSheet 实现底部弹出框更多:作者 提 Bug 标签:DialogFragment-BottomSheet-
ScreenShots
SetUp
Gradle
Step 1. Add the JitPack repository to your build fileAdd it in your root build.gradle at the end of repositories:allprojects { repositories { ... maven { url 'https://jitpack.io' } } }Step 2. Add the dependency
dependencies { compile 'com.github.fccaikai:BottomMenuTutorial:1.1.0' }
Maven
Step 1. Add the JitPack repository to your build file<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>Step 2. Add the dependency
<dependency> <groupId>com.github.fccaikai</groupId> <artifactId>BottomMenuTutorial</artifactId> <version>1.0.2</version> </dependency>
Usage
Defalut
BottomDialog dialog = BottomDialog.newInstance("title",new String[]{"item1","item2"}); /** * * BottomDialog dialog = BottomDialog.newInstance("titleText","cancelText",new String[]{"item1","item2"}); * * use public static BottomDialog newInstance(String titleText,String cancelText, String[] items) * set cancel text */ dialog.show(getChildFragmentManager(),"dialog"); //add item click listener dialog.setListener(new BottomDialog.OnClickListener() { @Override public void click(int position) { Toast.makeText(getContext(), "" + position, Toast.LENGTH_LONG).show(); } });
Custom
custom dialog text size & color if need. in your appcorlor.xmldefine :
<color name="bottom_lib_dialog_item_text_color">your dialog item color</color> <color name="bottom_lib_dialog_title_text_color">your dialog title color</color> <color name="bottom_lib_dialog_cancel_text_color">your dialog cancel color1</color>
dimen.xmldefine:
<dimen name="bottom_lib_dialog_item_text">your dialog item text size,default 16sp</dimen> <dimen name="bottom_lib_dialog_title_text">your dialog title text title,default 18sp</dimen> <dimen name="bottom_lib_dialog_cancel_text">your dialog title cancel title,default 18sp</dimen>custom dialog padding:
<dimen name="bottom_lib_dialog_padding_top">12dp</dimen> <dimen name="bottom_lib_dialog_padding_bottom">12dp</dimen> <dimen name="bottom_lib_dialog_padding_left">12dp</dimen> <dimen name="bottom_lib_dialog_padding_right">12dp</dimen>
相关文章推荐
- Android使用BottomSheetBehavior 和 BottomSheetDialog实现底部弹窗
- BottomDialog 是一个通过 DialogFragment 实现的底部弹窗布局,并且支持弹出动画,支持任意布局http://shaohui.me
- 使用BottomTabBar+Fragment实现底部导航页
- 使用DialogFragment从底部弹出对话框
- 自定义 DialogFragment 实现底部弹出 dialog
- BottomSheetDialogFragment 的使用
- 底部弹出DialogFragment中使用ViewPager,ViewPager中使用Fragment出现Fragment does not have a view错误
- 如何使用Material Design中的BottomSheetBehavior、BottomSheetDialog和BottomSheetDialogFragment
- Android实现底部对话框BottomDialog弹出实例代码
- 如何禁止使用bottomsheetdialogfragment拖动?
- 如何禁止使用bottomsheetdialogfragment拖动?
- Bottom Sheet的使用和BottomSheetDialogFragment的封装
- Android BottomSheetDialog实现底部对话框的示例
- Android使用CoordinatorLayout和BottomSheetBehavior实现滑动效果(底部抽屉)
- BottomSheetDialog底部弹出框、butterkoife使用
- Android 6.0新控件 BottomSheetDialog | 底部对话框 介绍及使用详情
- Android底部对话框的实现(BottomSheet,自定义Dialog)
- [Android] BottomBar+ViewPager+Fragment实现炫酷的底部导航效果20160523
- 使用ViewPager和Fragment实现底部导航滑动重构版
- android使用Fragment实现底部菜单使用show()和hide()来切换以保持Fragment状态