From 317ebf6c805a30bb20ef232257b414484914d787 Mon Sep 17 00:00:00 2001 From: bowyer-app Date: Thu, 6 Aug 2015 21:25:19 +0900 Subject: [PATCH] add bottom sheet --- .../demo/MainActivity.java | 32 +- demo/src/main/res/layout/activity_main.xml | 29 ++ .../BottomSheetLayout.java | 441 ++++++++++++++++++ .../main/res/layout/bottom_sheet_layout.xml | 27 ++ .../src/main/res/layout/sheet_layout.xml | 28 +- 5 files changed, 550 insertions(+), 7 deletions(-) create mode 100644 fabtransitionlayout/src/main/java/com/bowyer/app/fabtransitionlayout/BottomSheetLayout.java create mode 100644 fabtransitionlayout/src/main/res/layout/bottom_sheet_layout.xml diff --git a/demo/src/main/java/com/bowyer/fabtransitionlayout/demo/MainActivity.java b/demo/src/main/java/com/bowyer/fabtransitionlayout/demo/MainActivity.java index 6ba947b..c225fd2 100644 --- a/demo/src/main/java/com/bowyer/fabtransitionlayout/demo/MainActivity.java +++ b/demo/src/main/java/com/bowyer/fabtransitionlayout/demo/MainActivity.java @@ -1,5 +1,6 @@ package com.bowyer.fabtransitionlayout.demo; +import com.bowyer.app.fabtransitionlayout.BottomSheetLayout; import com.bowyer.app.fabtransitionlayout.FooterLayout; import com.github.ksoichiro.android.observablescrollview.ObservableListView; import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks; @@ -8,14 +9,13 @@ import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; +import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v7.app.ActionBarActivity; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ImageView; +import android.widget.ListView; import java.util.ArrayList; import java.util.List; @@ -31,8 +31,15 @@ public class MainActivity extends ActionBarActivity implements ObservableScrollV ObservableListView mObservableListView; @InjectView(R.id.fabtoolbar) FooterLayout mFabToolbar; + @InjectView(R.id.fablist) + BottomSheetLayout mFooterLayout; + @InjectView(R.id.list_menu) + ListView mListView; + @InjectView(R.id.fab) FloatingActionButton mFab; + @InjectView(R.id.fab_left) + FloatingActionButton mFabLeft; @InjectView(R.id.ic_call) ImageView mIcCall; @@ -47,9 +54,21 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_main); ButterKnife.inject(this); initListView(); + initListMenu(); mFabToolbar.setFab(mFab); + mFooterLayout.setFab(mFabLeft); } + private void initListMenu(){ + List menu = new ArrayList<>(); + menu.add("Share"); + menu.add("Upload"); + menu.add("Fav"); + ArrayAdapter adapter = new ArrayAdapter(this, + android.R.layout.simple_list_item_1, menu); + mListView.setAdapter(adapter); + + } private void initListView() { List list = new ArrayList(100); for (int i = 0; i < 100; i++) { @@ -76,8 +95,10 @@ public void onDownMotionEvent() { public void onUpOrCancelMotionEvent(ScrollState scrollState) { if (scrollState == ScrollState.UP) { mFabToolbar.slideOutFab(); + mFooterLayout.slideOutFab(); } else if (scrollState == ScrollState.DOWN) { mFabToolbar.slideInFab(); + mFooterLayout.slideInFab(); } } @@ -86,6 +107,11 @@ void onFabClick() { mFabToolbar.expandFab(); } + @OnClick(R.id.fab_left) + void onFabLeftClick(){ + mFooterLayout.expandFab(); + } + @OnClick(R.id.call) void onClickCall() { iconAnim(mIcCall); diff --git a/demo/src/main/res/layout/activity_main.xml b/demo/src/main/res/layout/activity_main.xml index 44c271d..4665db1 100644 --- a/demo/src/main/res/layout/activity_main.xml +++ b/demo/src/main/res/layout/activity_main.xml @@ -18,11 +18,40 @@ android:layout_gravity="bottom|end" android:layout_marginBottom="32dp" android:layout_marginRight="32dp" + android:visibility="invisible" android:src="@drawable/ic_add_white_24dp" app:borderWidth="0dp" app:fabSize="normal" app:rippleColor="@color/primary" /> + + + + + + + + + + + + + diff --git a/fabtransitionlayout/src/main/res/layout/sheet_layout.xml b/fabtransitionlayout/src/main/res/layout/sheet_layout.xml index ab8ed1a..35a6d8e 100644 --- a/fabtransitionlayout/src/main/res/layout/sheet_layout.xml +++ b/fabtransitionlayout/src/main/res/layout/sheet_layout.xml @@ -1,7 +1,27 @@ - + + + + +