Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
plugins {
id "com.android.application"
id "kotlin-android"
}

android {
compileSdkVersion 26
compileSdkVersion 33
defaultConfig {
applicationId "com.lpirro.constraintlayoutanimations"
minSdkVersion 21
targetSdkVersion 26
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.20"
implementation "androidx.appcompat:appcompat:1.5.1"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
}
21 changes: 0 additions & 21 deletions app/proguard-rules.pro

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,43 @@
package com.lpirro.constraintlayoutanimations

import android.os.Bundle
import android.support.constraint.ConstraintSet
import android.support.v7.app.AppCompatActivity
import android.transition.ChangeBounds
import android.transition.TransitionManager
import android.view.View
import android.view.animation.AnticipateOvershootInterpolator
import kotlinx.android.synthetic.main.circuit.*
import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet

class MainActivity : AppCompatActivity() {

private var show = false
lateinit var constraintLayout: ConstraintLayout

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.circuit)

constraintLayout = findViewById(R.id.constraint)

val backgroundImage = findViewById<View>(R.id.backgroundImage)
backgroundImage.setOnClickListener {
if(show)
hideComponents() // if the animation is shown, we hide back the views
else
showComponents() // if the animation is NOT shown, we animate the views
show = !show
if (show) changeConstraints(R.layout.circuit_detail) // if the animation is NOT shown, we animate the views
else changeConstraints(R.layout.circuit) // if the animation is shown, we hide back the views
}
}

private fun showComponents(){
show = true

val constraintSet = ConstraintSet()
constraintSet.clone(this, R.layout.circuit_detail)

val transition = ChangeBounds()
transition.interpolator = AnticipateOvershootInterpolator(1.0f)
transition.duration = 1200

TransitionManager.beginDelayedTransition(constraint, transition)
constraintSet.applyTo(constraint) //here constraint is the name of view to which we are applying the constraintSet
}

private fun hideComponents(){
show = false

private fun changeConstraints(@LayoutRes newConstraintLayout: Int) {
val constraintSet = ConstraintSet()
constraintSet.clone(this, R.layout.circuit)
constraintSet.clone(this, newConstraintLayout)

val transition = ChangeBounds()
transition.interpolator = AnticipateOvershootInterpolator(1.0f)
transition.duration = 1200

TransitionManager.beginDelayedTransition(constraint, transition)
constraintSet.applyTo(constraint) //here constraint is the name of view to which we are applying the constraintSet
TransitionManager.beginDelayedTransition(constraintLayout, transition)
constraintSet.applyTo(constraintLayout) //here constraint is the name of view to which we are applying the constraintSet
}
}
7 changes: 4 additions & 3 deletions app/src/main/res/layout/circuit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
Expand All @@ -21,6 +21,7 @@
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JUNE 3, 2018"
Expand Down Expand Up @@ -51,7 +52,7 @@

<View
android:id="@+id/fadeBackgroudView"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="90dp"
android:foreground="@drawable/gradient_variant"
app:layout_constraintBottom_toTopOf="@+id/description" />
Expand Down Expand Up @@ -86,4 +87,4 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>

</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
52 changes: 27 additions & 25 deletions app/src/main/res/layout/circuit_detail.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
Expand All @@ -23,46 +24,40 @@
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:background="#F44336"
android:paddingBottom="8dp"
android:paddingEnd="24dp"
android:paddingStart="24dp"
android:paddingTop="8dp"
android:paddingEnd="24dp"
android:paddingBottom="8dp"
android:text="Mugello Circuit"
android:textColor="#FFFF"
android:textSize="45sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="JUNE 3, 2018"
app:layout_constraintRight_toRightOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/title"
android:textSize="12sp"
android:background="#d3d3d3"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingTop="3dp"
android:paddingBottom="3dp"/>

<View
android:id="@+id/fadeBackgroudView"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:foreground="@drawable/gradient"
app:layout_constraintBottom_toTopOf="@+id/description" />
android:paddingEnd="16dp"
android:paddingBottom="3dp"
android:text="JUNE 3, 2018"
android:textSize="12sp"
app:layout_constraintRight_toRightOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/title" />

<TextView
android:id="@+id/tap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Tap for info"
android:textSize="15sp"
android:textColor="#ffffff"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand All @@ -71,17 +66,24 @@
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="The Mugello is a historic region and valley in northern Tuscany, in Italy. It is located to the north of the city of Florence and consists of the northernmost portion of the Metropolitan City of Florence. It is connected to the separate Santerno river valley by the Futa Pass."
android:textSize="22sp"
android:textColor="#FFFF"
android:gravity="center"
android:background="#181818"
android:gravity="center"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingBottom="8dp"
android:text="The Mugello is a historic region and valley in northern Tuscany, in Italy. It is located to the north of the city of Florence and consists of the northernmost portion of the Metropolitan City of Florence. It is connected to the separate Santerno river valley by the Futa Pass."
android:textColor="#FFFF"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
app:layout_constraintRight_toRightOf="parent" />

<View
android:id="@+id/fadeBackgroudView"
android:layout_width="match_parent"
android:layout_height="30dp"
android:foreground="@drawable/gradient"
app:layout_constraintBottom_toTopOf="@+id/description" />


</android.support.constraint.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

This file was deleted.

25 changes: 4 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
plugins {
id "com.android.application" version "7.2.1" apply false
id "com.android.library" version "7.2.1" apply false
id "org.jetbrains.kotlin.android" version "1.7.20" apply false
}

task clean(type: Delete) {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ org.gradle.jvmargs=-Xmx1536m
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

android.useAndroidX=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Feb 04 11:49:22 CET 2018
#Sun Jun 13 10:34:00 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
Loading