当前位置: 首页 > 软件库 > 手机/移动开发 > >

Bubble-Picker

授权协议 Readme
开发语言 Kotlin
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 仲孙凡
操作系统 Android
开源组织
适用人群 未知
 软件概览

Bubble-Picker

Get it on Google Play

Check this project on dribbble

Read how we did it on Medium

Requirements

  • Android SDK 16+

Usage

Add to your root build.gradle:

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

Add the dependency:

dependencies {
	compile 'com.github.igalata:Bubble-Picker:v0.2.4'
}

How to use this library

Add BubblePicker to your xml layout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.igalata.bubblepicker.rendering.BubblePicker
        android:id="@+id/picker"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:backgroundColor="@android:color/white" />

</FrameLayout>

Override onResume() and onPause() methods to call the same methods from the BubblePicker

Kotlin

override fun onResume() {
      super.onResume()
      picker.onResume()
}

override fun onPause() {
      super.onPause()
      picker.onPause()
}

Java

@Override
protected void onResume() {
      super.onResume();
      picker.onResume();
}

@Override
protected void onPause() {
      super.onPause();
      picker.onPause();
}

Pass the PickerItem list to the BubblePicker

Kotlin

val titles = resources.getStringArray(R.array.countries)
val colors = resources.obtainTypedArray(R.array.colors)
val images = resources.obtainTypedArray(R.array.images)

picker.adapter = object : BubblePickerAdapter {

            override val totalCount = titles.size

            override fun getItem(position: Int): PickerItem {
                return PickerItem().apply {
                    title = titles[position]
                    gradient = BubbleGradient(colors.getColor((position * 2) % 8, 0),
                            colors.getColor((position * 2) % 8 + 1, 0), BubbleGradient.VERTICAL)
                    typeface = mediumTypeface
                    textColor = ContextCompat.getColor(this@DemoActivity, android.R.color.white)
                    backgroundImage = ContextCompat.getDrawable(this@DemoActivity, images.getResourceId(position, 0))
                }
            }
}

Java

final String[] titles = getResources().getStringArray(R.array.countries);
final TypedArray colors = getResources().obtainTypedArray(R.array.colors);
final TypedArray images = getResources().obtainTypedArray(R.array.images);

picker.setAdapter(new BubblePickerAdapter() {
            @Override
            public int getTotalCount() {
                return titles.length;
            }

            @NotNull
            @Override
            public PickerItem getItem(int position) {
                PickerItem item = new PickerItem();
                item.setTitle(titles[position]);
                item.setGradient(new BubbleGradient(colors.getColor((position * 2) % 8, 0),
                        colors.getColor((position * 2) % 8 + 1, 0), BubbleGradient.VERTICAL));
                item.setTypeface(mediumTypeface);
                item.setTextColor(ContextCompat.getColor(DemoActivity.this, android.R.color.white));
                item.setBackgroundImage(ContextCompat.getDrawable(DemoActivity.this, images.getResourceId(position, 0)));
                return item;
            }
});

Specify the BubblePickerListener to get notified about events

Kotlin

picker.listener = object : BubblePickerListener {
            override fun onBubbleSelected(item: PickerItem) {

            }

            override fun onBubbleDeselected(item: PickerItem) {

            }
}

Java

picker.setListener(new BubblePickerListener() {
            @Override
            public void onBubbleSelected(@NotNull PickerItem item) {
                
            }

            @Override
            public void onBubbleDeselected(@NotNull PickerItem item) {

            }
});

To get all selected items use picker.selectedItems variable in Kotlin or picker.getSelectedItems() method in Java.

For more usage examples please review the sample app

Changelog

Version: 0.2.4

  • Added a possibility to setup the BubblePicker using BubblePickerAdapter

Version: 0.2.3

  • Fixed black textures issue on some devices

Version: 0.2.1

  • BubblePicker.centerImmediately veriable added, so it's possible to place the bubblesin the center of the view immediately

Version: 0.2

  • icon parameter added to place an image on a bubble along with the title
  • iconOnTop parameter added to control position of the icon on a bubble
  • textSize parameter added
  • BubblePicker.bubbleSize variable now can be changed from 1 to 100

Known iOS versions of the animation

License

MIT License

Copyright (c) 2017 Irina Galata

Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.

 相关资料
  • This plugin adds bubbling functionality to jQuery. The code is similar to jQuery.fn.trigger's because it's meant to extend it. It also generates it's own event object, that will remain untouched throu

  • 以下是基本气泡图的示例。 我们已经在Google Charts Configuration Syntax一章中看到了用于绘制图表的配置 。 现在,让我们看一个泡泡图的例子。 配置 (Configurations) 我们使用BubbleChart类来显示基本的气泡图。 // bubble chart BubbleChart chart = new BubbleChart(); 例子 (Exampl

  • 气泡图用于种植三维数据; 第三个维度将由气泡的大小(半径)表示。 以下是描绘完成工作的气泡图。 在JavaFX中,气泡图由名为BubbleChart的类BubbleChart 。 该类属于包javafx.scene.chart 。 通过实例化此类,您可以在JavaFX中创建BubbleChart节点。 生成气泡图的步骤 要在JavaFX中生成气泡图,请按照以下步骤操作。 第1步:创建一个类 创建一

  • Bubble Navigation �� A light-weight library to easily make beautiful Navigation Bars with a ton of �� customization options. Demos FloatingTopBarActivity TopBarActivity BottomBarActivity EqualBottomBa

  • Bubble Tea 是一个基于 The Elm Architecture 的 Go 框架。Bubble Tea 非常适用于简单和复杂的终端应用,可以是内联的、也可以是全窗口的,或者是两者的混合。构建终端应用程序的有趣的、功能性的和有状态的方式。 Bubble Tea 已在生产中使用,包括了许多功能和性能优化。其中包括一个标准的基于帧率的渲染器、一个与主渲染器一起工作的高性能可滚动区域的渲染器,以及鼠标支持。

  • Bubble Engine是一个漂亮的jQuery插件,它非常成功的模仿了冒气泡动画。它可以让你利用JavaScript控制最大和最小气泡的大小,气泡图片,气泡产生的位置和方向,气泡消失时间等。 在线演示:http://www.soyos.net/tl_files/demos/bubbles/ 配置选项 泡沫引擎是一个肥皂泡粒子发射器模拟。大小,位置看图形的,等可以自由调节。 最小粒径 粒子的最大