Need help with DragView?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

tuanhav95
188 Stars 25 Forks Apache License 2.0 18 Commits 3 Opened issues

Description

Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube New graphic component.

Services available

!
?

Need anything else?

Contributors list

DragView

Alt text

Download

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }


    dependencies {
        implementation 'com.github.tuanhav95:DragView:1.1.0'
}

Using Detail code java

  • Xml
   

Alt text | Alt text --- | ---

  • Listener
        dragView.setDragListener(object : DragView.DragListener {
            override fun onChangeState(state: DragView.State) {
            }

        override fun onChangePercent(percent: Float) {
            alpha.alpha = 1 - percent
        }

    })

  • Add frame
        supportFragmentManager.beginTransaction().add(R.id.frameFirst, TopFragment()).commit() // add frame top
        supportFragmentManager.beginTransaction().add(R.id.frameSecond, BottomFragment()).commit() // add frame bottom

Alt text

  • Action
        btnMax.setOnClickListener { dragView.maximize() }
        btnMin.setOnClickListener { dragView.minimize() }
        btnClose.setOnClickListener { dragView.close() }

Custom Detail code java

  • Custom ```java class DragSource @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : DragView(context, attrs, defStyleAttr) {

    var mWidthWhenMax = 0
    
    

    var mWidthWhenMiddle = 0

    var mWidthWhenMin = 0

    init { getFrameFirst().addView(inflate(R.layout.layout_top)) getFrameSecond().addView(inflate(R.layout.layout_bottom)) }

    override fun initFrame() { mWidthWhenMax = width

    mWidthWhenMiddle = (width - mPercentWhenMiddle * mMarginEdgeWhenMin).toInt()

    mWidthWhenMin = mHeightWhenMin * 22 / 9

    super.initFrame() }

    override fun refreshFrameFirst() { super.refreshFrameFirst()

    val width = if (mCurrentPercent < mPercentWhenMiddle) { (mWidthWhenMax - (mWidthWhenMax - mWidthWhenMiddle) * mCurrentPercent) } else { (mWidthWhenMiddle - (mWidthWhenMiddle - mWidthWhenMin) * (mCurrentPercent - mPercentWhenMiddle) / (1 - mPercentWhenMiddle)) }

    frameTop.reWidth(width.toInt()) }

    } ```

  • Xml

    java
    
    
  • Code

        dragView.setDragListener(object : DragView.DragListener {
            override fun onChangeState(state: DragView.State) {
            }

        override fun onChangePercent(percent: Float) {
            alpha.alpha = 1 - percent
            shadow.alpha = percent
        }

    })

    supportFragmentManager.beginTransaction().add(R.id.frameTop, TopFragment()).commit()
    supportFragmentManager.beginTransaction().add(R.id.frameBottom, BottomFragment()).commit()

    btnMax.setOnClickListener { dragView.maximize() }
    btnMin.setOnClickListener { dragView.minimize() }
    btnClose.setOnClickListener { dragView.close() }

Hello

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.