Convert Figma logo to code with AI

zzz40500 logoAndroidSweetSheet

一个富有动感的Sheet(选择器)

2,063
365
2,063
22

Top Related Projects

:octocat: 📃 FoldingCell is a material design expanding content cell inspired by folding paper material made by @Ramotion

Give a custom shape to any android view, Material Design 2 ready

Implementation of ExpandableListview with custom header and custom content.

You can easily add awesome animated context menu to your app.

Android Floating Action Button based on Material Design specification

Quick Overview

AndroidSweetSheet is an Android library that provides a customizable bottom sheet UI component. It offers a sleek and animated way to display additional options or information from the bottom of the screen, similar to the bottom sheets found in many popular apps.

Pros

  • Smooth and customizable animations for showing and hiding the sheet
  • Multiple built-in styles (fatup, sweet, and custom)
  • Easy integration with existing Android projects
  • Supports both vertical and horizontal layouts

Cons

  • Limited documentation and examples
  • Not actively maintained (last update was several years ago)
  • May not be fully compatible with the latest Android versions or Material Design guidelines
  • Lacks some advanced features found in more recent bottom sheet implementations

Code Examples

  1. Basic implementation of a SweetSheet:
SweetSheet sweetSheet = new SweetSheet(parentView);
sweetSheet.setMenuList(R.menu.menu_sweet);
sweetSheet.setDelegate(new ViewPagerDelegate());
sweetSheet.show();
  1. Using a custom style:
CustomDelegate customDelegate = new CustomDelegate(true,
        CustomDelegate.AnimationType.DuangLayoutAnimation);
customDelegate.setCustomView(R.layout.layout_custom_sweet);
sweetSheet.setDelegate(customDelegate);
  1. Handling item selection:
sweetSheet.setOnMenuItemClickListener(new SweetSheet.OnMenuItemClickListener() {
    @Override
    public boolean onItemClick(int position, MenuEntity menuEntity) {
        // Handle item click
        return false;
    }
});

Getting Started

To use AndroidSweetSheet in your project:

  1. Add the JitPack repository to your root build.gradle:
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app's build.gradle:
dependencies {
    implementation 'com.github.zzz40500:AndroidSweetSheet:1.1.0'
}
  1. In your activity or fragment, create and show a SweetSheet:
SweetSheet sweetSheet = new SweetSheet(findViewById(R.id.parentView));
sweetSheet.setMenuList(R.menu.your_menu);
sweetSheet.setDelegate(new RecyclerViewDelegate(true));
sweetSheet.show();

Competitor Comparisons

:octocat: 📃 FoldingCell is a material design expanding content cell inspired by folding paper material made by @Ramotion

Pros of folding-cell-android

  • More sophisticated animation with a folding effect
  • Better suited for displaying detailed content expansions
  • Actively maintained with recent updates

Cons of folding-cell-android

  • More complex implementation compared to AndroidSweetSheet
  • Limited to a specific folding cell design, less versatile

Code Comparison

AndroidSweetSheet:

mSweetSheet = new SweetSheet(rl_main);
mSweetSheet.setMenuList(R.menu.menu_sweet);
mSweetSheet.setDelegate(new ViewPagerDelegate());
mSweetSheet.toggle();

folding-cell-android:

val foldingCell = findViewById<FoldingCell>(R.id.folding_cell)
foldingCell.setOnClickListener {
    foldingCell.toggle(false)
}

AndroidSweetSheet offers a simpler implementation for basic bottom sheets, while folding-cell-android provides a more intricate folding animation but requires more setup. AndroidSweetSheet is more flexible for various sheet styles, whereas folding-cell-android focuses on a specific folding cell design. Both libraries serve different purposes and can be chosen based on the specific UI requirements of the project.

Give a custom shape to any android view, Material Design 2 ready

Pros of ShapeOfView

  • More versatile, allowing for various shape transformations beyond just bottom sheets
  • Supports custom shapes through path definitions
  • Easier integration with existing views and layouts

Cons of ShapeOfView

  • Lacks specific bottom sheet functionality
  • May require more custom code for complex interactions
  • Not specifically optimized for bottom sheet use cases

Code Comparison

ShapeOfView:

<com.github.florent37.shapeofview.shapes.CircleView
    android:layout_width="150dp"
    android:layout_height="150dp"
    app:shape_circle_borderColor="@android:color/black"
    app:shape_circle_borderWidth="2dp">
    <!-- Your content here -->
</com.github.florent37.shapeofview.shapes.CircleView>

AndroidSweetSheet:

mSweetSheet = new SweetSheet(fl);
mSweetSheet.setMenuList(R.menu.list);
mSweetSheet.setDelegate(new ViewPagerDelegate());
mSweetSheet.toggle();

While AndroidSweetSheet provides a more specialized solution for bottom sheets with pre-built menu functionality, ShapeOfView offers greater flexibility for creating custom-shaped views throughout an application. ShapeOfView requires more manual setup for specific use cases like bottom sheets but allows for more diverse shape transformations. AndroidSweetSheet is more focused on providing a quick and easy bottom sheet implementation with built-in menu support.

Implementation of ExpandableListview with custom header and custom content.

Pros of ExpandableLayout

  • Focused on a specific UI component (expandable layouts)
  • Simpler implementation for basic expandable views
  • Lightweight and easy to integrate into existing projects

Cons of ExpandableLayout

  • Limited to expandable layouts, less versatile than AndroidSweetSheet
  • Fewer customization options for animations and styling
  • Less active development and community support

Code Comparison

ExpandableLayout:

ExpandableLayout expandableLayout = findViewById(R.id.expandable_layout);
expandableLayout.setExpandInterpolator(new BounceInterpolator());
expandableLayout.setCollapseInterpolator(new DecelerateInterpolator());
expandableLayout.toggle();

AndroidSweetSheet:

mSweetSheet = new SweetSheet(rl_main);
mSweetSheet.setMenuList(R.menu.list);
mSweetSheet.setDelegate(new ViewPagerDelegate());
mSweetSheet.toggle();

Both libraries offer simple methods to toggle their respective UI components. ExpandableLayout focuses on expanding and collapsing a single view, while AndroidSweetSheet provides a more complex bottom sheet implementation with various delegate options and menu integration.

You can easily add awesome animated context menu to your app.

Pros of Context-Menu.Android

  • More customizable appearance with various animation options
  • Supports both vertical and horizontal menu layouts
  • Better documentation and examples provided in the repository

Cons of Context-Menu.Android

  • Limited to context menu functionality, less versatile than AndroidSweetSheet
  • Slightly more complex implementation compared to AndroidSweetSheet
  • May require more setup code for basic usage

Code Comparison

Context-Menu.Android:

MenuParams menuParams = new MenuParams();
menuParams.setActionBarSize((int) getResources().getDimension(R.dimen.tool_bar_height));
menuParams.setMenuObjects(getMenuObjects());
menuParams.setClosableOutside(false);
mMenuDialogFragment = ContextMenuDialogFragment.newInstance(menuParams);

AndroidSweetSheet:

mSweetSheet = new SweetSheet(fl);
mSweetSheet.setMenuList(R.menu.list);
mSweetSheet.setDelegate(new RecyclerViewDelegate(true));
mSweetSheet.setBackgroundEffect(new DimEffect(0.5f));
mSweetSheet.show();

Both libraries offer unique approaches to creating interactive menus in Android applications. Context-Menu.Android focuses on providing a highly customizable context menu with various animation options, while AndroidSweetSheet offers a more versatile bottom sheet implementation. The choice between the two depends on the specific requirements of your project and the desired user experience.

Android Floating Action Button based on Material Design specification

Pros of FloatingActionButton

  • Focused specifically on implementing Material Design floating action buttons
  • Provides more customization options for FAB appearance and behavior
  • Easier to integrate for projects primarily needing FAB functionality

Cons of FloatingActionButton

  • Limited to FAB implementation, less versatile for other UI components
  • May require additional libraries for more complex UI interactions
  • Less suitable for projects needing comprehensive bottom sheet solutions

Code Comparison

FloatingActionButton:

<com.github.clans.fab.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:fab_colorNormal="@color/colorPrimary"
    app:fab_size="normal" />

AndroidSweetSheet:

mSweetSheet = new SweetSheet(rootView);
mSweetSheet.setMenuList(R.menu.menu_sweet);
mSweetSheet.setDelegate(new ViewPagerDelegate());
mSweetSheet.toggle();

While FloatingActionButton focuses on implementing Material Design FABs with extensive customization options, AndroidSweetSheet offers a more comprehensive solution for creating interactive bottom sheets with various layouts and animations. FloatingActionButton is ideal for projects specifically needing FAB functionality, while AndroidSweetSheet provides a versatile toolkit for creating rich bottom sheet experiences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

一个富有动感的 Sheet, 先发两张图: 原型.GIF

效果图.gif

Android Arsenal

Android Gems

我的微博

###gradle
/build.gradle

repositories {
    maven {
        url "https://jitpack.io"
    }
}

/app/build.gradle

compile 'com.github.zzz40500:AndroidSweetSheet:1.1.0'

###Usage:


// SweetSheet 控件,根据 rl 确认位置
mSweetSheet = new SweetSheet(rl);

//设置数据源 (数据源支持设置 list 数组,也支持从menu 资源中获取)
mSweetSheet.setMenuList(list);
//根据设置不同的 Delegate 来显示不同的风格.
mSweetSheet.setDelegate(new RecyclerViewDelegate(true));
//根据设置不同Effect来设置背景效果:BlurEffect 模糊效果.DimEffect 变暗效果,NoneEffect 没有效果.
mSweetSheet.setBackgroundEffect(new BlurEffect(8));
//设置菜单点击事件
mSweetSheet.setOnMenuItemClickListener(new SweetSheet.OnMenuItemClickListener() {
    @Override
    public boolean onItemClick(int position, MenuEntity menuEntity1) {

        //根据返回值, true 会关闭 SweetSheet ,false 则不会.
        Toast.makeText(MainActivity.this, menuEntity1.title + "  " + position, Toast.LENGTH_SHORT).show();
        return true;
    }
});

自定义扩展:


// SweetSheet 控件,根据 rl 确认位置
mSweetSheet3 = new SweetSheet(rl);
//定义一个 CustomDelegate 的 Delegate ,并且设置它的出现动画.
CustomDelegate customDelegate = new CustomDelegate(true,
        CustomDelegate.AnimationType.DuangLayoutAnimation);
View view = LayoutInflater.from(this).inflate(R.layout.layout_custom_view, null, false);
//设置自定义视图.
customDelegate.setCustomView(view);
//设置代理类
mSweetSheet3.setDelegate(customDelegate);
//因为使用了 CustomDelegate 所以mSweetSheet3中的 setMenuList和setOnMenuItemClickListener就没有效果了
view.findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        mSweetSheet3.dismiss();
    }
});

监听返回

    @Override
    public void onBackPressed() {
 
        if(mSweetSheet.isShow()){

            mSweetSheet.dismiss();
        }
        else{
            super.onBackPressed();
        }
    }

###v1.1(版本说明)

  1. 去掉之前ViewPager 使用FragmentStatePagerAdapter 做为它的适配器.
  • SweetSheet 不支持 LinearLayout 作为它的父控件.

  • setMenuList 设置数据源支持从 List数组和Menu资源的填充.(Menu仅支持一级Menu,因为2级Menu我还没想好怎么展示).

  • setBackgroundEffect(Effect effect) 提供对背景效果的支持,目前提供3种风格: BlurEffect:模糊效果,DimEffect 变暗效果,NoneEffect 没有效果. 你也可以继承Effect扩展背景的效果

  • setDelegate 目前提供了三种风格 RecyclerViewDelegate,ViewPagerDelegate,CustomDelegate.

  • CustomDelegate用于扩展类,你可以使用通过构造方法指定出现动画,通过setCustomView(View v)来设置你的自定义的布局.

  • CustomDelegate中提供了4种类型: DuangLayoutAnimation,DuangAnimation, AlphaAnimation,Custom: 看名字大概就能知道它是什么效果.如果你对前3个效果不满意你就使用 Custom ,然后通过setCustomViewAnimation设置出现效果.

  • CRImageView 内部实现了 Android 5.0上面的CircleReveal效果.使用方法:CRImageView. circularReveal(int centerX, int centerY, float startRadius, float endRadius, long duration, Interpolator interpolator)你可以在你的项目中用上它.

###FAQ 怎么使包括 actionBar 在内的背景也虚化? 使用 一个 FrameLayout或者RelativeLayout 里面使用 ToolBar 来替代 ActionBar 将这个 FrameLayout 或者RelativeLayout作为SweetSheet 的父控件传递进去,