Giter VIP home page Giter VIP logo

android-actionsheet's Introduction

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.5'
}

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

android-actionsheet's People

Contributors

baoyongzhang avatar brx0826 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.