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

aashrai/Skittles: Material design FAB menu made easy

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

开源软件名称(OpenSource Name):

aashrai/Skittles

开源软件地址(OpenSource Url):

https://github.com/aashrai/Skittles

开源编程语言(OpenSource Language):

Java 100.0%

开源软件介绍(OpenSource Introduction):

#Skittles Android Arsenal Build Status Jcenter JitPackv

A simple,clean api for adding PushBullet style skittles to your app for more material design glory.This library uses the FloatingActionButton provided in the android design support library

##Guide (Sample)

First some housekeeping code:

Use SkittleLayout as a root view in your layouts

<snow.skittles.SkittleLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/skittleLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:mainSkittleColor="@color/material_deep_teal_500"
app:mainSkittleIcon="@drawable/ic_android_white_18dp"
tools:context=".MainActivity">

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/appBarMaxHeight"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
...

</snow.skittles.SkittleLayout>

Some further housekeeping...

Declare a SkittleBuilder,used to add skittles and pass the root SkittleLayout to it

SkittleLayout skittleLayout = (SkittleLayout) findViewById(R.id.skittleLayout);
//Pass false as the second param if you don't want the menu to be closed on screen tap
SkittleBuilder skittleBuilder = SkittleBuilder.newInstance((SkittleLayout) findViewById(R.id.skittleLayout), true);

Now for the fun part

Add skittles to your activity/fragment

skittleBuilder.addSkittle(Skittle.newInstance(ContextCompat.getColor(this, R.color.barratheon),
        ContextCompat.getDrawable(this, R.drawable.barratheon_icon)));
skittleBuilder.addSkittle(Skittle.newInstance(ContextCompat.getColor(this, R.color.lannister),
        ContextCompat.getDrawable(this, R.drawable.lannister_icon)));

Add TextSkittle to your activity/fragment

 skittleBuilder.addSkittle(new TextSkittle.Builder("Hello", ContextCompat.getColor(this, R.color.stark),
            ContextCompat.getDrawable(this, R.drawable.stark_icon)).setTextBackground(
            ContextCompat.getColor(this, android.R.color.background_light)).build());

Flexible callback for clicks:

  • Add a click listener(SkittleBuilder.SkittleClickListener) to the SkittleBuilder object skittleBuilder.setSkittleListener(this);

  • This exposes two methods for Skittle and MainSkittle click events

void onSkittleClick(BaseSkittle skittle, int position); 

void onMainSkittleClick();

BaseSkittle is an interface that every skittle implements

public void onSkittleClick(BaseSkittle skittle, int position) {
  if(skittle instanceOf TextSkittle)
   ...
  else if(skittle instanceOf Skittle)
   ...
}

Here the position does not include the mainSkittle and starts from 0

You can now create your very own Skittle you just have to implement the BaseSkittle, check TextSkittle or Skittle for further reference

##Snackbar Support

When using snackbars ensure that you use SkittleContainer

Snackbar.make(skittleLayout.getSkittleContainer(), "Skittle Pressed", Snackbar.LENGTH_LONG)
.show();

##Gradle

dependencies{
compile 'com.rlj.library:skittles:4.1.1'
}

See the Sample and JavaDoc for further guidance

##Upcoming

  • Better support for animations
  • Option for adding skittles by xml (inspired by Navigation View)

#Taste the rainbow ![Skittles](art/Taste the rainbow.jpg)




鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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