Giter VIP home page Giter VIP logo

nothinglogin's Introduction

NothingLogin

使用Kotlin仿的Nothing的登录页面(练习)

1、Demo预览

image

2、动画实现

fun showOrHide(isShow: Boolean) {
    isShowing = isShow
    val valueAnimator: ValueAnimator = if (isShow) {
        ValueAnimator.ofInt(0, (getScreenHeight() * 2f / 3f).toInt())
    } else {
        ValueAnimator.ofInt((getScreenHeight() * 2f / 3f).toInt(), 0)
    }
    valueAnimator.addUpdateListener { a ->
        val value = a.animatedValue as Int
        val params = loginBottomLayout.layoutParams
        params.height = value
        loginBottomLayout.layoutParams = params
        Log.d("addUpdateListener", value.toString())
    }
    valueAnimator.duration = 500
    valueAnimator.setTarget(loginBottomLayout)
    valueAnimator.start()
}

3、下滑关闭登录或注册

loginBottomLayout.setOnTouchListener(object : View.OnTouchListener {
    var lastX: Float = -1F
    var lastY: Float = -1F
    override fun onTouch(view: View?, event: MotionEvent): Boolean {
        when (event.action) {
            MotionEvent.ACTION_DOWN -> {
                lastY = event.y
                lastX = event.x
                Log.d("ACTION_DOWN", "x:$lastX,y:$lastY")
            }
            MotionEvent.ACTION_UP -> {
                if (Math.abs(event.x - lastX) < 30 && event.y - lastY > 30) {       //向下滑动逻辑,
                    if (isShowing)
                        showOrHide(false)           //关闭登录或注册
                }
                Log.d("ACTION_UP", "x:${event.x},y:${event.y}")
            }
        }

        return true
    }

})

nothinglogin's People

Contributors

leiyun1993 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

yinxh2016

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.