# DraggablePanel **Repository Path**: coolblood/DraggablePanel ## Basic Information - **Project Name**: DraggablePanel - **Description**: Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-12 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Draggable Panel =============== Draggable Panel is an Android library created to build a draggable user interface similar to the new YouTube draggable video component based on Fragments or Views. This Android library offers you two main classes to use and create your own awesome user interfaces. If you want to use it with fragments add ``DraggablePanel`` to your layout. If you want to use it with views use ``DraggableView`` and put your views inside. This new component has been created using some concepts described on [Flavien Laurent Blog][1] and [Denevell Blog][2]. To create this library I've used an Android component called [ViewDragHelper][3] and [ViewDragHelper.Calback][4]. This component doesn't have too much documentation and that's the reason why I've added some javadoc to my code in order to clarify the component usage. This library works on Android 4.X because the scale effect is not going to work properly when the user try to drag the view. The clickable zone on a scaled view in Android 2.X is bigger than the real scaled zone. Screenshots ----------- [Download demo application from Google Play Store][18] ![Demo Screenshot 1][5] ![Demo Screenshot 2][6] ![Demo Screenshot 4][7] ![Demo Screenshot 3][8] Usage ----- To use Draggable Panel library and get your new awesome UI working you can use two different Android widgets: * 1. Add ``DraggablePanel`` widget to your layout. Configure the view customization elements using styleable attributes or programatically and configure your fragments to work as top or bottom fragment inside the ``DraggablePanel`` widget. ```xml ``` ```java private void initializeDraggablePanel() throws Resources.NotFoundException { draggablePanel.setFragmentManager(getSupportFragmentManager()); draggablePanel.setTopFragment(placeFragment); draggablePanel.setBottomFragment(mapFragment); draggablePanel.initializeView(); } ``` * 2. Add ``DraggableView`` widget to your layout. Configure the view to use two children views as the draggable view and the second view. Configure the customization elements using styleable attributes or programatically. ```xml ``` Usage ----- Download the project, compile it using ```mvn clean install``` import ``draggablepanel-1.0.0.apklib`` into your project. Or declare it into your pom.xml com.github.pedrovgs draggablepanel 1.0.0 apklib Or into your build.gradle dependencies{ compile 'com.github.pedrovgs:draggablepanel:1.0.0' } Customization ------------- You can customize some of the view effects programatically or using xml styleable attributes. The elements to customize are: * Draggable view / fragment height. * Draggable view X scale factor. * Draggable view Y scale factor. * Draggable view margin right applied when the view is minimized. * Draggable view margin bottom applied when the view is minimized. * Enable or disable the horizontal alpha effect applied while the view is being horizontally dragged. ```xml ....... ``` ```java draggablePanel.setTopFragment(placeFragment); draggablePanel.setBottomFragment(mapFragment); draggablePanel.setXScaleFactor(xScaleFactor); draggablePanel.setYScaleFactor(yScaleFactor); draggablePanel.setTopViewHeight(topViewHeight); draggablePanel.setTopFragmentMarginRight(topViewMarginRight); draggablePanel.setTopFragmentMarginBottom(topViewMargnBottom); ``` Similar customizable attributes are available programatically or using styleable attributes in ``DraggableView``. TODO ---- I don't have too much time to work on this library and I'm going to put in this section some things to do in the future: * Create other draggable component to resize elements instead of scale the view. This new component is needed to drag and resize videos. Developed By ------------ * Pedro Vicente Gómez Sánchez - Follow me on Twitter Add me to Linkedin Who's using it -------------- * [El Rubius Vídeos][9] using the first beta release. *Does your app use DraggablePanel? If you want to be featured on this list tell me on [Twitter][10] Libraries used on the sample project ------------------------------------ * [Renderers][11] * [Dagger][12] * [Butterknife][13] * [NineOldAndroids][14] * [Picasso][15] * [ActionBarSherlock][16] * [YouTube Player][17] License ------- Copyright 2014 Pedro Vicente Gómez Sánchez Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. [1]: http://flavienlaurent.com/blog/2013/08/28/each-navigation-drawer-hides-a-viewdraghelper/ [2]: http://blog.denevell.org/android-viewdraghelper-example-tutorial.html [3]: http://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.html [4]: http://developer.android.com/reference/android/support/v4/widget/ViewDragHelper.Callback.html [5]: ./art/screenshot1.gif [6]: ./art/screenshot2.gif [7]: ./art/screenshot3.gif [8]: ./art/screenshot4.gif [9]: https://play.google.com/store/apps/details?id=com.nero.elrubiusomg [10]: https://twitter.com/pedro_g_s [11]: https://github.com/pedrovgs/Renderers [12]: https://github.com/square/dagger [13]: https://github.com/JakeWharton/butterknife [14]: https://github.com/JakeWharton/NineOldAndroids/ [15]: https://github.com/square/picasso [16]: http://actionbarsherlock.com/ [17]: https://developers.google.com/youtube/android/player/ [18]: https://play.google.com/store/apps/details?id=com.github.pedrovgs.sample