All Projects → denizavsar → Draggablelayout

denizavsar / Draggablelayout

Draggable XML Layout for Android

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Draggablelayout

Etree
parse and generate XML easily in go
Stars: ✭ 763 (+2834.62%)
Mutual labels:  xml
Xml Comp
Compare ANY markup documents.
Stars: ✭ 16 (-38.46%)
Mutual labels:  xml
Cheatyxml
CheatyXML is a Swift framework designed to manage XML easily
Stars: ✭ 23 (-11.54%)
Mutual labels:  xml
Macsvg
macSVG - An open-source macOS app for designing HTML5 SVG (Scalable Vector Graphics) art and animation with a WebKit web view ➤➤➤
Stars: ✭ 789 (+2934.62%)
Mutual labels:  xml
Cardinalpgm Maps
Make OCN Great Again!
Stars: ✭ 6 (-76.92%)
Mutual labels:  xml
Wed
Wed is a web-based editor that assists users in editing XML documents according to a schema.
Stars: ✭ 17 (-34.62%)
Mutual labels:  xml
Textfieldboxes
Material Design text field that comes in a box, based on (OLD) Google Material Design guidelines.
Stars: ✭ 760 (+2823.08%)
Mutual labels:  xml
Music Player
Android xml template layout for media/music player.
Stars: ✭ 24 (-7.69%)
Mutual labels:  xml
Easyxml
Simplifies parsing and modifying of (huge) XML streams (files) based on the StAX parser with combination of JAXB or JDom2
Stars: ✭ 6 (-76.92%)
Mutual labels:  xml
Xylophone
Xylophone
Stars: ✭ 23 (-11.54%)
Mutual labels:  xml
Vue Moveable
↔️ ↕️ 🔄 Vue.js wrapper for Moveable
Stars: ✭ 792 (+2946.15%)
Mutual labels:  draggable
Draggableflagview
可拖拽的红点,(仿新版QQ,tab下面拖拽标记为已读的效果),拖拽一定的距离可以消失回调。
Stars: ✭ 811 (+3019.23%)
Mutual labels:  draggable
Vast Parser
Recursively requests and parses VAST chains into a single JavaScript object.
Stars: ✭ 18 (-30.77%)
Mutual labels:  xml
Scrollbooster
Enjoyable content drag-to-scroll library
Stars: ✭ 775 (+2880.77%)
Mutual labels:  draggable
Snowflake
❄️ SVG in Swift
Stars: ✭ 924 (+3453.85%)
Mutual labels:  xml
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+2819.23%)
Mutual labels:  xml
Fuzi
A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
Stars: ✭ 894 (+3338.46%)
Mutual labels:  xml
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: ✭ 24 (-7.69%)
Mutual labels:  xml
Formdraggerdemo
一个可在窗体内随意拖动窗体的方案
Stars: ✭ 24 (-7.69%)
Mutual labels:  draggable
Amazon Mobile Sentiment Analysis
Opinion mining of Mobile reviews on Amazon platform
Stars: ✭ 19 (-26.92%)
Mutual labels:  xml

Draggable XML Layout

There are TWO usage of this library.

  1. DraggableFrameLayout
  2. DraggableScrollViewLayout

Use DraggableFrameLayout for your activities that does not contain any scrollable content! (Story, Image, etc.)

Use DraggableScrollViewLayout for your activities that contain scrollable content! (Look for the second gif)

Java example can be found here: Class / XML

Installation

implementation "com.github.denizavsar:DraggableLayout:5.1.1"

Usage

Add android:theme="@style/Draggable.NoActionBar" on your activity decleration on AndroidManifest.xml

<activity
    android:name=".MainActivity"
    android:theme="@style/Draggable.NoActionBar" />

Add overridePendingTransition(R.anim.draggable_enter_animation, 0) before super.onCreate(savedInstanceState) on your activity class

override fun onCreate(savedInstanceState: Bundle?) {
    overridePendingTransition(R.anim.draggable_enter_animation, 0)
    super.onCreate(savedInstanceState)
}

You can merge Draggable styles (Draggable.NoActionBar, Draggable.FullScreen) with your own styles on styles.xml

<style name="StoryScreen" parent="Draggable.FullScreen">
    <item name="colorPrimary">@color/primary_color</item>
    <item name="colorPrimaryDark">@color/primary_color_dark</item>
    <item name="colorAccent">@color/accent_color</item>
    <!-- more items -->
</style>

and use it like on your AndroidManifest.xml

<activity
    android:name=".MainActivity"
    android:theme="@style/StoryScreen" />

IMPORTANT 1

If you are going to use Draggable.FullScreen style, you should put that code in your onCreate method before the setContentView(...)

override fun onCreate(savedInstanceState: Bundle?) {
    overridePendingTransition(R.anim.draggable_enter_animation, 0)
    super.onCreate(savedInstanceState)
    
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
    }
    
    setContentView(R.layout.activity_main)
}

IMPORTANT 2

If you use ViewPager (or something like listen to left and right swipe events) inside DraggableLayout, you should only enable moveable directions (top and bottom) with app:draggableDirections="top|bottom" to prevent the DraggableLayout catch the left and right swipe events!


DraggableFrameLayout

This xml layout is suitable for instagram like stories swipe down to close feature. draggableDirections is set to bottom so you can only start the drag operation with hold and swipe down gesture

<com.deniz.draggablelibrary.DraggableFrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    app:draggableCorners="topLeft|topRight"
    app:draggableMaxCornerRadius="40dp"
    app:draggableScaleFactor="0.5"
    app:draggableDirections="bottom">

</com.deniz.draggablelibrary.DraggableFrameLayout>

Example: Class / XML


DraggableScrollViewLayout

This xml layout is for activities that contain scrollable content. Just wrap your ScrollView with DraggableScrollViewLayout!

<com.deniz.draggablelibrary.DraggableScrollViewLayout 
    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"
    app:draggableCorners="all"
    app:draggableDirections="all"
    app:draggableMaxCornerRadius="50dp"
    app:draggableMinCornerRadius="5dp">
    
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    </ScrollView>

</com.deniz.draggablelibrary.DraggableScrollViewLayout>

Example: Class / XML

You are ready to go!

Detailed Usage

  • Listeners
// DraggableFrameLayout - DragListener

val root = findViewById<DraggableFrameLayout>(R.id.root)

root.setDragListener(object : DraggableFrameLayout.DragListener {
    override fun onDragStarted(rawX: Float, rawY: Float) {
        // DO YOUR WORK HERE
    }

    override fun onDrag(rawX: Float, rawY: Float, touchDeltaX: Float, touchDeltaY: Float) {
        // DO YOUR WORK HERE
    }

    override fun onDragFinishing(distance: Float) {
        // DO YOUR WORK HERE
    }

    override fun onDragFinished() {
        // DO YOUR WORK HERE
    }
})
// DraggableScrollViewLayout - ScrollListener

val layout = findViewById<DraggableScrollViewLayout>(R.id.root)

layout.setScrollListener(object : DraggableScrollViewLayout.ScrollListener {
    override fun onScrollStarted(rawX: Float, rawY: Float) {
        // DO YOUR WORK HERE
    }

    override fun onScroll(scrollX: Int, scrollY: Int) {
        // DO YOUR WORK HERE
    }

    override fun onScrollFinished() {
        // DO YOUR WORK HERE
    }
})
  • Xml Attributes

draggableMinCornerRadius

Usage       : app:draggableMinCornerRadius="15dp"
Default     : 0F
Format      : dimension
Limitations : draggableMinCornerRadius >= 0F
Explanation : See 'draggableCorners' attribute

draggableMaxCornerRadius

Usage       : app:draggableMaxCornerRadius="40dp"
Default     : 0F
Format      : dimension
Limitations : draggableMaxCornerRadius >= draggableMinCornerRadius
Explanation : See 'draggableCorners' attribute

draggableDetectionAngle (Only works with DraggableFrameLayout)

Usage       : app:draggableDetectionAngle="45"
Default     : 90F
Format      : float
Limitations : 0 <= draggableDetectionAngle <= 90

draggableBackgroundColor

Usage       : app:draggableBackgroundColor="@color/black"
Default     : #000000
Format      : color
Limitations : -

draggableBackgroundOpacityMin

Usage       : app:draggableBackgroundOpacityMin="100"
Default     : 70F
Format      : float
Limitations : draggableBackgroundOpacityMin >= 0

draggableBackgroundOpacityMax

Usage       : app:draggableBackgroundOpacityMax="155"
Default     : 255F
Format      : float
Limitations : draggableBackgroundOpacityMax >= draggableBackgroundOpacityMin

draggableTransparentBackground

Usage       : app:draggableTransparentBackground="true"
Default     : false
Format      : boolean
Limitations : -
Explanation : If true, draggableBackgroundOpacityMin and draggableBackgroundOpacityMax is useless

draggableScaleFactor

Usage       : app:draggableScaleFactor="0.5"
Default     : 0.6F
Format      : float
Limitations : 0.1 <= draggableScaleFactor <= 1.0
Explanation : Higher factor means less scale | (1.0 = no scale) , (0.1 = highest scale)

draggableScaleEnabled

Usage       : app:draggableScaleEnabled="true"
Default     : true
Format      : boolean
Limitations : -
Explanation : If false, draggableScaleFactor is useless

draggableExitAnimation

Usage       : app:draggableExitAnimation="@anim/alpha_out_animation"
Default     : R.anim.draggable_exit_animation
Format      : reference
Limitations : -

draggableFinishOffset

Usage       : app:draggableFinishOffset="100dp"
Default     : 0F
Format      : dimension
Limitations : -

draggableCorners

Usage       : app:draggableCorners="topLeft|topRight"
Default     : none
Format      : flag
Limitations : none - topLeft - topRight - bottomLeft - bottomRight - all
Explanation : Determine the corners that will have radius with drag event

draggableDirections

Usage       : app:draggableDirections="bottom"
Default     : none
Format      : flag
Limitations : none - top - bottom - left - right - all
Explanation : Determine the layout moveable directions

draggableDistanceAxis

Usage       : app:draggableDistanceAxis="y"
Default     : all
Format      : flag
Limitations : none - x - y - all
Explanation : Determine which axis should be used for distance calculation
  • In Class Attributes
val layout = findViewById<DraggableScrollViewLayout>(R.id.root)

layout.setConfig()
            .setMinCornerRadius(15)
            .setMaxCornerRadius(35)
            .setTransparentBackground(false)
            .setBackgroundColorOpacityMin(70F)
            .setBackgroundColorOpacityMax(200F)
            .setScaleEnabled(true)
            .setScaleFactor(0.6)
            .setFinishOffset(60F)
            .apply()

Examples

Instagram Story -> Class / XML

ScrollView -> Class / XML

Image Display -> Class / XML

Bottom Sheet -> Class / XML

You can clone this project for the detailed examples and usages of draggable layout

Contributing

Pull requests are welcome.

For major changes, please open an issue first to discuss what you would like to change.

License

MIT License

Copyright (c) 2020 Fırat Deniz Avşar, Connected2.me

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

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

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, 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 THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].