View mobile control via Viewhelper.settranslationy in Android (Nineoldandroids Open source project)

Source: Internet
Author: User

We know there are many open source projects that can achieve a lot of good results. A few days ago, I looked at an effect, and the jar package was used in the project. Nothing to dig a dig to learn (a talk about digging a dig, then the problem comes, the excavator technology in the end which strong), see how the effect of good to achieve it? What is the specific meaning of a function? Many effects, we do not need to re-build the wheel, only need to assemble the wheel, drive up on it , you do not have so much time to build wheels , we can choose their favorite wheels, open our Lamborghini, open our Porsche concept car, open up !

Let's look at the effect first! Dug from Open source project (nineoldandroids Open source project )

No nonsense. We explain the correlation function.

Private View header_logo;private Float Movedistancey = 25;//logo initial move distance is 10private float Movedistancex = 25;//logo initial move distance is 1 0@overridepublic void OnClick (View v) {switch (V.getid ()) {case R.id.btn_movedown:movedistancey + = 20; Viewhelper.settranslationy (Header_logo, Movedistancey); break;case R.id.btn_moveup:movedistancey-= 20; Viewhelper.settranslationy (Header_logo, Movedistancey); break;case R.id.btn_moveleft:movedistancex-= 20; Viewhelper.settranslationx (Header_logo, Movedistancex); Break;case R.id.btn_moveright:movedistancex + = 20; Viewhelper.settranslationx (Header_logo, Movedistancex); break;default:break;}}


About the interpretation of the viewhelper.settranslationy (view,float) function. The view here is which view you want to move and what is it that you want to do with the interface? Float refers to the distance you move, assuming the center position at the beginning of the reference coordinates is 0. So Viewhelper.settranslationy (view,100) is to move the view downward (more than the original position) 100, then 120 that 130 that 140 150?

is more than the original position 10, more than 20, more than 30, more than 40 .... So Viewhelper.settranslationx or viewhelper.settranslationy can be achieved. Let's go to the source code. Or you can not see the effect is to scold me. Rattle.


To use viewhelper, you need to refer to the jar package. Open Source Project Jar Package

The source of the project: hit here, after a week to ensure that a weekly update of the latest technical articles, every day to try to tap the technical points (not open excavators, open excavators or go to the Blue Xiang Kai). Or do you think I've been out of breath for so long? Or was hit by a car, the hospital can not get up ....





View mobile control via Viewhelper.settranslationy in Android (Nineoldandroids Open source project)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.