Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✨ An easy way to implement an elastic touch effect for Android.

License

NotificationsYou must be signed in to change notification settings

skydoves/ElasticViews

Repository files navigation

LicenseAPIBuild StatusAndroid WeeklyJavadoc

✨ An easy way to implement an elastic touch effect for Android.

Including in your project

Maven CentralKitpack

Gradle

Add codes below to yourrootbuild.gradle file (not your module build.gradle file).

allprojects {    repositories {        mavenCentral()    }}

And add a dependency code to yourmodule'sbuild.gradle file.

dependencies {    implementation"com.github.skydoves:elasticviews:2.1.0"}

SNAPSHOT

ElasticViews
Snapshots of the current development version of ElasticViews are available, which trackthe latest versions.

repositories {   maven { url'https://oss.sonatype.org/content/repositories/snapshots/' }}

Usage

ElasticViews lets we use like using normal views and gives all of the Views or GroupViews touch effect very simply.

Add XML Namespace

First add below XML Namespace inside your XML layout file.

xmlns:app="http://schemas.android.com/apk/res-auto"

OnClick Method

All of ElasticViews should be setOnClickListener oronClick method. If not, nothing happens.

ElasticButtonelasticButton = (ElasticButton)findViewById(R.id.elasticbutton);elasticButton.setOnClickListener(newView.OnClickListener() {@OverridepublicvoidonClick(Viewv) {// do something    }});

ElasticButton

<com.skydoves.elasticviews.ElasticButtonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:text="Elastic Button"android:textColor="@android:color/white"android:textSize="17sp"app:button_cornerRadius="4dp"app:button_duration="250"app:button_scale="0.87"/>

ElasticCheckButton

<com.skydoves.elasticviews.ElasticCheckButtonandroid:layout_width="match_parent"android:layout_height="45dp"android:background="#30354b"android:text="Text"android:textColor="@android:color/white"android:textStyle="bold"app:checkButton_cornerRadius="4dp"app:checkButton_alpha="0.7"app:checkButton_duration="400"app:checkButton_scale="0.9"/>

ElasticImageView

<com.skydoves.elasticviews.ElasticImageViewandroid:layout_width="23dp"android:layout_height="23dp"android:scaleType="fitXY"android:src="@drawable/ic_question"android:tint="#3d95c9"app:imageView_scale="0.7"app:imageView_duration="300"/>

ElasticFloatingActionButton

<com.skydoves.elasticviews.ElasticFloatingActionButtonandroid:layout_width="64dp"android:layout_height="64dp"android:src="@drawable/ic_add"android:tint="#ffffff"app:fabSize="normal"app:fabutton_duration="400"app:fabutton_scale="0.85"/>

ElasticCardView

<com.skydoves.elasticviews.ElasticCardViewandroid:layout_width="match_parent"android:layout_height="120dp"app:cardCornerRadius="8dp"app:cardElevation="12dp"app:cardBackgroundColor="@color/background"app:cardView_duration="250"app:cardView_scale="0.8">...</com.skydoves.elasticviews.ElasticCardView>

ElasticLayout

ElasticLayout gives elastic animation to all child views.

<com.skydoves.elasticviews.ElasticLayoutandroid:layout_width="match_parent"android:layout_height="80dp"app:layout_cornerRadius="4dp"app:layout_duration="500"app:layout_scale="0.85"><TextViewandroid:id="@+id/textView0"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="This is"android:textColor="#ffffff"android:textSize="18sp"/><TextViewandroid:layout_below="@+id/textView1"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:text="ElasticLayout"android:textColor="#ffffff"android:textSize="18sp"android:gravity="end"/></com.skydoves.elasticviews.ElasticLayout>

ElasticAnimation

ElasticAnimation implements elastic animations for android views and view groups.

newElasticAnimation(clickedView).setScaleX(0.9f).setScaleY(0.9f).setDuration(400).setOnFinishListener(onFinishListener).doAction();

ViewPropertyAnimatorListener

we can setViewPropertyAnimatorListener usingsetListener method and detect animation's status.

.setListener(newViewPropertyAnimatorListener() {@OverridepublicvoidonAnimationStart(Viewview) {// do something   }OverridepublicvoidonAnimationEnd(Viewview) {finishListener.onFinished();   }OverridepublicvoidonAnimationCancel(Viewview) {// do something   }});

Kotlin Extension

ElasticAnimation supports kotlin extensionelasticAnimation.

val anim= textView.elasticAnimation(0.8f,0.8f,400,object:ElasticFinishListener {overridefunonFinished() {// do anything    }})anim.doAction()

Kotlin dsl

elasticAnimation(this) {  setDuration(duration)  setScaleX(scale)  setScaleY(scale)  setOnFinishListener(object:ElasticFinishListener {overridefunonFinished() {           onClick()      }  })}.doAction()

Example : Normal Button

we can implement animation on all of the views like below.

@OnClick(R.id.button)publicvoidaddNewAlarm(Viewv){// implements animation uising ElasticAnimationnewElasticAnimation(v).setScaleX(0.85f).setScaleY(0.85f).setDuration(500)    .setOnFinishListener(newElasticFinishListener() {@OverridepublicvoidonFinished() {// Do something after duration time            }        }).doAction();    }}

Example : ListView Item

So also we can implement animation on listView's items like below.

privateclassListViewItemClickListenerimplementsAdapterView.OnItemClickListener {@OverridepublicvoidonItemClick(AdapterView<?>adapterView,ViewclickedView,finalintpos,longid) {newElasticAnimation(clickedView).setScaleX(0.9f).setScaleY(0.9f).setDuration(400)        .setOnFinishListener(newElasticFinishListener() {@OverridepublicvoidonFinished() {// Do something after duration timeToast.makeText(getBaseContext(),"ListViewItem" +pos,Toast.LENGTH_SHORT).show();              }          }).doAction();        }    };

Find this library useful? ❤️

Support it by joiningstargazers for this repository. ⭐
Andfollow me for my next creations! 🤩

License

The MIT License (MIT)Copyright (c) 2017 skydovesPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 INTHE SOFTWARE.

About

✨ An easy way to implement an elastic touch effect for Android.

Topics

Resources

License

Stars

Watchers

Forks

Contributors4

  •  
  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp