Skip to content

Commit

Permalink
Adding Vector Asset Animations for Buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Girish85 committed Aug 17, 2017
1 parent 09c60f1 commit 159424b
Show file tree
Hide file tree
Showing 43 changed files with 697 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Vector Assets on Buttons/Expe/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
22 changes: 22 additions & 0 deletions Vector Assets on Buttons/Expe/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Vector Assets on Buttons/Expe/.idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions Vector Assets on Buttons/Expe/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Vector Assets on Buttons/Expe/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Vector Assets on Buttons/Expe/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Vector Assets on Buttons/Expe/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions Vector Assets on Buttons/Expe/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.usgir.expe"
minSdkVersion 25
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
25 changes: 25 additions & 0 deletions Vector Assets on Buttons/Expe/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\usgir\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.usgir.expe;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.example.usgir.expe", appContext.getPackageName());
}
}
21 changes: 21 additions & 0 deletions Vector Assets on Buttons/Expe/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.usgir.expe">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.usgir.expe;

import android.animation.ObjectAnimator;
import android.support.graphics.drawable.AnimatedVectorDrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final AnimatedVectorDrawableCompat vectorDrawableCompat = AnimatedVectorDrawableCompat.create(getApplicationContext(),R.drawable.vectdrawable);
final Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (vectorDrawableCompat!=null)
{
button.setBackground(vectorDrawableCompat);
vectorDrawableCompat.start();
}
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="100"
android:propertyName="pathData"
android:valueType="pathType"
android:valueFrom="M 20 0.1 L 19.9 0.05 L 19.8 0.05"
android:valueTo="M 20 0.1 L 12 1 L 15 2"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:propertyName="translateX"
android:valueFrom="0"
android:valueTo="-150"
android:startOffset="100"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="100"
android:propertyName="fillColor"
android:valueType="colorType"
android:valueFrom="#FF4081"
android:valueTo="#c059"
android:startOffset="400"/>

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="15dp"/>
<solid android:color="@color/colorAccent"/>
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="658.0"
android:viewportWidth="395.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF4081"
android:pathData="M13.5,6.5c-5.7,2 -9.3,6.6 -10,12.9 -0.3,2.8 -0.5,144 -0.3,313.8l0.3,308.7 2.1,2.7c1.1,1.5 3.3,3.7 4.8,4.8l2.7,2.1 183.7,0 183.7,0 3.3,-2.3c1.8,-1.3 4,-3.8 5,-5.5 1.6,-3 1.7,-21 1.7,-315.2l0,-312 -2,-3.5c-1.2,-1.9 -3.6,-4.3 -5.5,-5.5 -3.5,-2 -4.4,-2 -184.5,-2.2 -153.8,-0.2 -181.6,0 -185,1.2z" android:strokeColor="#00000000"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<vector android:height="24dp" android:viewportHeight="22.5"
android:viewportWidth="21.5" android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<group android:name="nothing">
<path android:fillColor="#FF4081"
android:name="path1"
android:strokeWidth="0.01"
android:strokeColor="#ffffff"
android:pathData="M 1 0 L 20 0.1 S 21.2 0.3 21 0.5 L 21.01 22
S 20.5 22.2 20 22.4 L 1.1 22.4 S 0.4 22.2 0.4 22 L 0.4 0.9
S 0.54 0.5 1 0 "/>
</group>
<group android:name="trans2">
<path android:name="transpath2"
android:strokeColor="#c059"
android:strokeWidth="0.5"
android:fillColor="#000000"
android:pathData="M 20 0.1 L 16 0.05 L 15 2"/>
</group>
</vector>
21 changes: 21 additions & 0 deletions Vector Assets on Buttons/Expe/app/src/main/res/drawable/vect.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:height="24dp"
android:viewportWidth="21.5" android:viewportHeight="22.5">
<group android:name="group">
<path android:name="rect"
android:strokeColor="#ffffff"
android:fillColor="#FF4081"
android:strokeWidth="0.01"
android:pathData="M 1 0 L 20 0.1 S 21.2 0.3 21 0.5 L 21.01 22
S 20.5 22.2 20 22.4 L 1.1 22.4 S 0.4 22.2 0.4 22 L 0.4 0.9
S 0.54 0.5 1 0 "
/>
</group>
<group android:name="trans">
<path android:name="transpath"
android:strokeColor="#c059"
android:strokeWidth="0.5"
android:fillColor="#000000"
android:pathData="M 20 0.1 L 19.9 0.05 L 19.8 0.05"/>
</group>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/vect">
<target
android:animation="@animator/objanim"
android:name="transpath"/>
<target
android:animation="@animator/objanim2"
android:name="trans"/>
<target
android:animation="@animator/objanim3"
android:name="rect"/>
</animated-vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.usgir.expe.MainActivity">


<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/vect"
android:elevation="8dp"
android:fontFamily="sans-serif"
android:padding="30dp"
android:text="Click Me"
android:textAlignment="center"
android:textColor="@android:color/background_light"
android:textSize="18sp" />
</RelativeLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 159424b

Please sign in to comment.