项目作者: woxingxiao

项目描述 :
A vertical-handled and multi-panel support SlidingPanelLayout. 一个竖直方向的SlidingPanelLayout,支持加载多个Panel,可以灵活地实现漂亮的的交互效果。
高级语言: Java
项目地址: git://github.com/woxingxiao/SlidingUpPanelLayout.git
创建时间: 2017-07-10T12:56:10Z
项目社区:https://github.com/woxingxiao/SlidingUpPanelLayout

开源协议:Apache License 2.0

关键词:
slidingpanelayout slidinguppanel

下载


SlidingUpPanelLayout


License

中文说明

logo

A powerful and flexible SlidingPanelLayout, which can support multiple panels in the vertical direction.


Screenshot

demo1
demo2

Download

1. sample apk

2. Gradle

root project:build.gradle

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url "https://jitpack.io" }
  5. }
  6. }

app:build.gradle

  1. dependencies {
  2. // e.g. compile 'com.github.woxingxiao:SlidingUpPanelLayout:1.1.0'
  3. compile 'com.github.woxingxiao:SlidingUpPanelLayout:${LATEST_VERSION}'
  4. }

Usage

1. java (Dynamic way)

  1. SlidingUpPanelLayout.setAdapter(new SlidingUpPanelLayout.Adapter() {
  2. private final int mSize = mWeatherList.size();
  3. @Override
  4. public int getItemCount() {
  5. return mSize;
  6. }
  7. @NonNull
  8. @Override
  9. public ISlidingUpPanel onCreateSlidingPanel(int position) {
  10. WeatherPanelView panel = new WeatherPanelView(DemoActivity1.this);
  11. if (position == 0) {
  12. panel.setSlideState(EXPANDED);
  13. } else {
  14. panel.setSlideState(HIDDEN);
  15. }
  16. return panel;
  17. }
  18. @Override
  19. public void onBindView(final ISlidingUpPanel panel, int position) {
  20. if (mSize == 0)
  21. return;
  22. BaseWeatherPanelView BasePanel = (BaseWeatherPanelView) panel;
  23. BasePanel.setWeatherModel(mWeatherList.get(position));
  24. BasePanel.setClickable(true);
  25. BasePanel.setOnClickListener(new View.OnClickListener() {
  26. @Override
  27. public void onClick(View v) {
  28. if (panel.getSlideState() != EXPANDED) {
  29. mSlidingUpPanelLayout.expandPanel();
  30. } else {
  31. mSlidingUpPanelLayout.collapsePanel();
  32. }
  33. }
  34. });
  35. }
  36. });

Go to sample for more details.

2. xml (Static way)

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <com.xw.repo.supl.SlidingUpPanelLayout
  3. android:id="@+id/sliding_up_panel_layout"
  4. xmlns:android="http://schemas.android.com/apk/res/android"
  5. xmlns:app="http://schemas.android.com/apk/res-auto"
  6. xmlns:tools="http://schemas.android.com/tools"
  7. android:layout_width="match_parent"
  8. android:layout_height="match_parent">
  9. <!-- background view, the position at 0 can only have one directly view, it can be a view or a layout. -->
  10. <android.support.constraint.ConstraintLayout
  11. android:id="@+id/bg_layout"
  12. android:layout_width="match_parent"
  13. android:layout_height="match_parent"
  14. android:background="#616161">
  15. <TextView
  16. android:id="@+id/pick_hint_text"
  17. android:layout_width="wrap_content"
  18. android:layout_height="wrap_content"
  19. android:layout_marginLeft="8dp"
  20. android:layout_marginRight="8dp"
  21. android:layout_marginTop="120dp"
  22. android:text="Pick a credit card to pay"
  23. android:textColor="@android:color/white"
  24. android:textSize="20sp"
  25. app:layout_constraintLeft_toLeftOf="parent"
  26. app:layout_constraintRight_toRightOf="parent"
  27. app:layout_constraintTop_toTopOf="parent"></TextView>
  28. <TextView
  29. android:id="@+id/pay_hint_text"
  30. android:layout_width="wrap_content"
  31. android:layout_height="wrap_content"
  32. android:layout_marginTop="260dp"
  33. android:alpha="0.0"
  34. android:drawablePadding="8dp"
  35. android:drawableTop="@mipmap/ic_finger_print"
  36. android:text="Pay with Touch ID"
  37. android:textColor="@android:color/white"
  38. android:textSize="18sp"
  39. app:layout_constraintLeft_toLeftOf="parent"
  40. app:layout_constraintRight_toRightOf="parent"
  41. app:layout_constraintTop_toTopOf="parent"
  42. tools:alpha="1.0"></TextView>
  43. </android.support.constraint.ConstraintLayout>
  44. <!-- panel view, the position from 1 to n must be the one which implemented the interface ISlidingUpPanel.-->
  45. <com.xw.sample.slidinguppanellayout.demo2.CardPanelView
  46. android:layout_width="match_parent"
  47. android:layout_height="match_parent"
  48. app:cpv_cardCount="4"
  49. app:cpv_cardImageRes="@mipmap/pic_card1"
  50. app:cpv_cardPosition="0"></com.xw.sample.slidinguppanellayout.demo2.CardPanelView>
  51. <com.xw.sample.slidinguppanellayout.demo2.CardPanelView
  52. android:layout_width="match_parent"
  53. android:layout_height="match_parent"
  54. app:cpv_cardCount="4"
  55. app:cpv_cardImageRes="@mipmap/pic_card2"
  56. app:cpv_cardPosition="1"></com.xw.sample.slidinguppanellayout.demo2.CardPanelView>
  57. <com.xw.sample.slidinguppanellayout.demo2.CardPanelView
  58. android:layout_width="match_parent"
  59. android:layout_height="match_parent"
  60. app:cpv_cardCount="4"
  61. app:cpv_cardImageRes="@mipmap/pic_card3"
  62. app:cpv_cardPosition="2"></com.xw.sample.slidinguppanellayout.demo2.CardPanelView>
  63. <com.xw.sample.slidinguppanellayout.demo2.CardPanelView
  64. android:layout_width="match_parent"
  65. android:layout_height="match_parent"
  66. app:cpv_cardCount="4"
  67. app:cpv_cardImageRes="@mipmap/pic_card4"
  68. app:cpv_cardPosition="3"></com.xw.sample.slidinguppanellayout.demo2.CardPanelView>
  69. </com.xw.repo.supl.SlidingUpPanelLayout>

Go to sample for more details.

Attentions

  • Your calculation must be accurate when your PanelView implement the interface ISlidingUpPanel,
    which can make sure SlidingUpPanelLayout to work properly. Generally my demos are good reference.
  • Don’t set onTouchListener for your PanelView in your own code, or may cause SlidingUpPanelLayout working abnormally.
  • Don’t load too many PanelViews because the recycling mechanism have not been considered.

Attributes

  1. <attr name="spl_disableSliding" format="boolean"></attr>
  2. <attr name="spl_expandThreshold" format="float"></attr>
  3. <attr name="spl_collapseThreshold" format="float"></attr>

Welcome to issue or pull request.

License

  1. Copyright 2017 woxingxiao
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.