• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

baoyongzhang/android-ActionSheet: iOS UIActionSheet for Android

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

baoyongzhang/android-ActionSheet

开源软件地址:

https://github.com/baoyongzhang/android-ActionSheet

开源编程语言:

Java 100.0%

开源软件介绍:

ActionSheet

Android Arsenal Download

This is like iOS UIActionSheet component, has iOS6 and iOS7 style, support custom style, background, button image, text color and spacing etc.

Screenshot    Screenshot

Usage

Add dependency

dependencies {
    compile 'com.baoyz.actionsheet:library:1.1.7'
}

Create ActionSheet and show

ActionSheet.createBuilder(this, getSupportFragmentManager())
				.setCancelButtonTitle("Cancel")
				.setOtherButtonTitles("Item1", "Item2", "Item3", "Item4")
				.setCancelableOnTouchOutside(true)
				.setListener(this).show();

Methods

  • setCancelButtonTitle() Cancel button title, (String)
  • setOtherButtonTitles() Item buttons title,(String[])
  • setCancelableOnTouchOutside() Touch outside to close, (boolean)
  • setListener() set a Listener to listen event
  • show() Show ActionSheet, return ActionSheet Object,call dismiss() method of ActionSheet to close.

Listen event

implementing ActionSheetListener interface.

  • onOtherButtonClick() Click item event,index is item index.
  • onDismiss() Dismiss event.
   	@Override
	public void onOtherButtonClick(ActionSheet actionSheet, int index) {
		Toast.makeText(getApplicationContext(), "click item index = " + index,
				0).show();
	}

	@Override
	public void onDismiss(ActionSheet actionSheet, boolean isCancle) {
		Toast.makeText(getApplicationContext(), "dismissed isCancle = " + isCancle, 0).show();
	}

Style

Default style is bad,ActionSheet has iOS6 and iOS7 style,you can configure the theme.

<!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <item name="actionSheetStyle">@style/ActionSheetStyleiOS6</item>
        or
        <item name="actionSheetStyle">@style/ActionSheetStyleiOS7</item>
    </style>

You can custom style, can refer to ActionSheetStyleiOS6/ActionSheetStyleiOS7 writing.

 <!-- iOS7 Style -->
 <style name="ActionSheetStyleiOS7">
        <item name="actionSheetBackground">@android:color/transparent</item>
        <item name="cancelButtonBackground">@drawable/slt_as_ios7_cancel_bt</item>
        <item name="otherButtonTopBackground">@drawable/slt_as_ios7_other_bt_top</item>
        <item name="otherButtonMiddleBackground">@drawable/slt_as_ios7_other_bt_middle</item>
        <item name="otherButtonBottomBackground">@drawable/slt_as_ios7_other_bt_bottom</item>
        <item name="otherButtonSingleBackground">@drawable/slt_as_ios7_other_bt_single</item>
        <item name="cancelButtonTextColor">#1E82FF</item>
        <item name="otherButtonTextColor">#1E82FF</item>
        <item name="actionSheetPadding">10dp</item>
        <item name="otherButtonSpacing">0dp</item>
        <item name="cancelButtonMarginTop">10dp</item>
        <item name="actionSheetTextSize">12sp</item>
    </style>

Style attributes

  • actionSheetBackground
  • cancelButtonBackground
  • otherButtonTopBackground
  • otherButtonMiddleBackground
  • otherButtonBottomBackground
  • otherButtonSingleBackground
  • cancelButtonTextColor
  • otherButtonTextColor
  • actionSheetPadding
  • otherButtonSpacing
  • cancelButtonMarginTop
  • actionSheetTextSize



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
AlphaWallet/alpha-wallet-ios: An advanced Ethereum/EVM mobile wallet发布时间:2022-06-21
下一篇:
mmrmilon/iOS: iOS libraries发布时间:2022-06-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap