| @@ -1,12 +1,27 @@ | |||||
| package de.mlte.soundboard | package de.mlte.soundboard | ||||
| import android.support.v7.app.AppCompatActivity | |||||
| import android.animation.ObjectAnimator | |||||
| import android.os.Bundle | import android.os.Bundle | ||||
| import android.support.v7.app.AppCompatActivity | |||||
| import android.widget.ProgressBar | |||||
| import android.widget.TextView | |||||
| class MainActivity : AppCompatActivity() { | class MainActivity : AppCompatActivity() { | ||||
| override fun onCreate(savedInstanceState: Bundle?) { | override fun onCreate(savedInstanceState: Bundle?) { | ||||
| super.onCreate(savedInstanceState) | super.onCreate(savedInstanceState) | ||||
| setContentView(R.layout.activity_main) | setContentView(R.layout.activity_main) | ||||
| val progressBar = findViewById<ProgressBar>(R.id.progress_bar) | |||||
| val objectAnimator = ObjectAnimator.ofInt(progressBar, "progress", progressBar.getProgress(), 100).setDuration(2000) | |||||
| val btn = findViewById<TextView>(R.id.text_view_button) | |||||
| objectAnimator.addUpdateListener({ valueAnimator -> | |||||
| val progress = valueAnimator.animatedValue as Int | |||||
| progressBar.progress = progress | |||||
| }) | |||||
| btn.setOnClickListener { | |||||
| objectAnimator.start() | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,44 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <item android:id="@android:id/background"> | |||||
| <shape> | |||||
| <gradient | |||||
| android:startColor="#777777" | |||||
| android:centerColor="#333333" | |||||
| android:centerY="0.75" | |||||
| android:endColor="#222222" | |||||
| android:angle="270" | |||||
| /> | |||||
| </shape> | |||||
| </item> | |||||
| <item android:id="@android:id/secondaryProgress"> | |||||
| <clip> | |||||
| <shape> | |||||
| <gradient | |||||
| android:startColor="#234" | |||||
| android:centerColor="#234" | |||||
| android:centerY="0.75" | |||||
| android:endColor="#a24" | |||||
| android:angle="270" | |||||
| /> | |||||
| </shape> | |||||
| </clip> | |||||
| </item> | |||||
| <item android:id="@android:id/progress"> | |||||
| <clip> | |||||
| <shape> | |||||
| <gradient | |||||
| android:startColor="#999999" | |||||
| android:centerColor="#777777" | |||||
| android:centerY="0.75" | |||||
| android:endColor="#555555" | |||||
| android:angle="270" | |||||
| /> | |||||
| </shape> | |||||
| </clip> | |||||
| </item> | |||||
| </layer-list> | |||||
| @@ -15,4 +15,29 @@ | |||||
| app:layout_constraintRight_toRightOf="parent" | app:layout_constraintRight_toRightOf="parent" | ||||
| app:layout_constraintTop_toTopOf="parent" /> | app:layout_constraintTop_toTopOf="parent" /> | ||||
| <FrameLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <ProgressBar | |||||
| android:id="@+id/progress_bar" | |||||
| style="?android:attr/progressBarStyleHorizontal" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:indeterminate="false" | |||||
| android:progressDrawable="@drawable/progress_bar_states" /> | |||||
| <TextView | |||||
| android:id="@+id/text_view_button" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:gravity="center" | |||||
| android:padding="6dp" | |||||
| android:text="Enter" | |||||
| android:textColor="@android:color/white" | |||||
| android:textSize="16sp" | |||||
| android:textStyle="bold" /> | |||||
| </FrameLayout> | |||||
| </android.support.constraint.ConstraintLayout> | </android.support.constraint.ConstraintLayout> | ||||