Skip to content

Commit db3c02b

Browse files
committed
Change login page background, from png to animation drawable
1 parent e5bb481 commit db3c02b

File tree

10 files changed

+82
-1
lines changed

10 files changed

+82
-1
lines changed

app/src/main/java/com/code4a/jlibrarydemo/login/LoginActivity.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.code4a.jlibrarydemo.login;
22

3+
import android.graphics.drawable.AnimationDrawable;
34
import android.os.Bundle;
45
import android.view.View;
56
import android.widget.EditText;
7+
import android.widget.RelativeLayout;
68

79
import com.code4a.jlibrary.base.AppActivity;
810
import com.code4a.jlibrary.base.BaseFragment;
@@ -22,6 +24,7 @@ public class LoginActivity extends AppActivity implements LoginView {
2224
EditText username;
2325
@BindView(R.id.password)
2426
EditText password;
27+
private AnimationDrawable anim;
2528
private CircularProgressButton circularButton;
2629
private LoginPresenter presenter;
2730

@@ -41,12 +44,31 @@ protected void onCreate(Bundle savedInstanceState) {
4144
setStatusBarColor(android.R.color.transparent, false);
4245
// username = $(R.id.username);
4346
// password = $(R.id.password);
47+
RelativeLayout container = $(R.id.id_login_layout);
48+
anim = (AnimationDrawable) container.getBackground();
49+
anim.setEnterFadeDuration(6000);
50+
anim.setExitFadeDuration(2000);
4451
circularButton = $(R.id.login_btn);
4552
circularButton.setOnClickListener(this);
4653

4754
presenter = new LoginPresenterImpl(this);
4855
}
4956

57+
// Starting animation:- start the animation on onResume.
58+
@Override
59+
protected void onResume() {
60+
super.onResume();
61+
if (anim != null && !anim.isRunning())
62+
anim.start();
63+
}
64+
65+
// Stopping animation:- stop the animation on onPause.
66+
@Override
67+
protected void onPause() {
68+
super.onPause();
69+
if (anim != null && anim.isRunning())
70+
anim.stop();
71+
}
5072

5173
@Override protected void onDestroy() {
5274
presenter.onDestroy();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#4776E6"
5+
android:endColor="#8E54E9"
6+
android:angle="90"/>
7+
</shape>

app/src/main/res/drawable/hot_bg.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#5f2c82"
5+
android:endColor="#49a09d"
6+
android:angle="45"/>
7+
</shape>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:drawable="@drawable/login_color1"
5+
android:duration="10000" />
6+
<item
7+
android:drawable="@drawable/login_color2"
8+
android:duration="10000" />
9+
<item
10+
android:drawable="@drawable/login_color3"
11+
android:duration="10000" />
12+
<item
13+
android:drawable="@drawable/login_color4"
14+
android:duration="10000" />
15+
</animation-list>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#614385"
5+
android:endColor="#516395"
6+
android:angle="0"/>
7+
</shape>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#5f2c82"
5+
android:endColor="#49a09d"
6+
android:angle="45"/>
7+
</shape>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#4776E6"
5+
android:endColor="#8E54E9"
6+
android:angle="90"/>
7+
</shape>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3+
<gradient
4+
android:startColor="#7141e2"
5+
android:endColor="#d46cb3"
6+
android:angle="135"/>
7+
</shape>

app/src/main/res/layout/activity_login.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:tools="http://schemas.android.com/tools"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/id_login_layout"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent"
67
android:paddingBottom="@dimen/activity_vertical_margin"
78
android:paddingLeft="@dimen/activity_horizontal_margin"
89
android:paddingRight="@dimen/activity_horizontal_margin"
910
android:paddingTop="@dimen/activity_vertical_margin"
10-
android:background="@drawable/login_bg"
11+
android:background="@drawable/login_animation_list"
1112
>
1213

1314
<LinearLayout

app/src/main/res/layout/fragment_category.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
44
android:layout_height="match_parent"
5+
android:background="@drawable/category_bg"
56
android:orientation="vertical">
67

78
<include layout="@layout/fragment_toolbar"/>

0 commit comments

Comments
 (0)