Skip to content

Commit ba719ba

Browse files
ymarianafohrman
authored andcommitted
Create a Bottom Nav Demo with animated vector drawables.
PiperOrigin-RevId: 234649780
1 parent b641bf7 commit ba719ba

21 files changed

+1222
-0
lines changed

catalog/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ android {
6262
targetSdkVersion 27
6363
}
6464

65+
aaptOptions {
66+
additionalParameters "--no-version-vectors"
67+
}
68+
6569
sourceSets {
6670
main {
6771
manifest.srcFile 'java/io/material/catalog/AndroidManifest.xml'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2019 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.material.catalog.bottomnav;
18+
19+
import io.material.catalog.R;
20+
21+
import android.os.Bundle;
22+
import androidx.annotation.Nullable;
23+
import android.view.LayoutInflater;
24+
import android.view.View;
25+
import android.view.ViewGroup;
26+
import io.material.catalog.feature.DemoFragment;
27+
28+
/**
29+
* A fragment that displays a bottom nav that uses {@link
30+
* android.graphics.drawable.AnimatedStateListDrawable} for icons.
31+
*/
32+
public class BottomNavigationAnimatedDemoFragment extends DemoFragment {
33+
34+
@Override
35+
public View onCreateDemoView(
36+
LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
37+
View view =
38+
layoutInflater.inflate(
39+
R.layout.cat_bottom_navs_animated, viewGroup, false /* attachToRoot */);
40+
return view;
41+
}
42+
}

catalog/java/io/material/catalog/bottomnav/BottomNavigationFragment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ public Fragment createFragment() {
7070
return new BottomNavigationColorStylesDemoFragment();
7171
}
7272
});
73+
additionalDemos.add(
74+
new Demo(R.string.cat_bottom_nav_animated_demo_title) {
75+
@Override
76+
public Fragment createFragment() {
77+
return new BottomNavigationAnimatedDemoFragment();
78+
}
79+
});
7380
return additionalDemos;
7481
}
7582

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<pathInterpolator
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:controlX1="0"
20+
android:controlX2="0.618865688196"
21+
android:controlY1="0"
22+
android:controlY2="1"/>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<pathInterpolator
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:controlX1="0.45921046959"
20+
android:controlX2="1"
21+
android:controlY1="0"
22+
android:controlY2="1"/>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<animated-vector
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:aapt="http://schemas.android.com/aapt"
20+
android:drawable="@drawable/vd_clock_stopwatch">
21+
22+
<target android:name="hand">
23+
<aapt:attr name="android:animation">
24+
<objectAnimator
25+
android:duration="1333"
26+
android:interpolator="@android:interpolator/fast_out_slow_in"
27+
android:propertyName="rotation"
28+
android:valueFrom="0"
29+
android:valueTo="360"/>
30+
</aapt:attr>
31+
</target>
32+
33+
<target android:name="button">
34+
<aapt:attr name="android:animation">
35+
<objectAnimator
36+
android:duration="267"
37+
android:pathData="M 12,12 c 0,0.16667 0,1 0,1 l 0,-1"
38+
android:propertyYName="translateY">
39+
<aapt:attr name="android:interpolator">
40+
<pathInterpolator
41+
android:pathData="M 0,0 C 0.2,0 0.1,0.5 0.5,0.5 C 0.7,0.5 0.6,1 1,1"/>
42+
</aapt:attr>
43+
</objectAnimator>
44+
</aapt:attr>
45+
</target>
46+
47+
</animated-vector>
48+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<animated-selector
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
tools:ignore="NewApi">
21+
<item
22+
android:id="@+id/state_on"
23+
android:drawable="@drawable/vd_clock_alarm"
24+
android:state_checked="true"/>
25+
<item
26+
android:id="@+id/state_off"
27+
android:drawable="@drawable/vd_clock_alarm"/>
28+
<transition
29+
android:drawable="@drawable/avd_clock_alarm"
30+
android:fromId="@id/state_off"
31+
android:toId="@id/state_on"/>
32+
</animated-selector>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<animated-selector
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
tools:ignore="NewApi">
21+
<item
22+
android:id="@+id/state_on"
23+
android:drawable="@drawable/vd_clock_clock"
24+
android:state_checked="true"/>
25+
<item
26+
android:id="@+id/state_off"
27+
android:drawable="@drawable/vd_clock_clock"/>
28+
<transition
29+
android:drawable="@drawable/avd_clock_clock"
30+
android:fromId="@id/state_off"
31+
android:toId="@id/state_on"/>
32+
</animated-selector>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<animated-selector
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
tools:ignore="NewApi">
21+
<item
22+
android:id="@+id/state_on"
23+
android:drawable="@drawable/vd_clock_stopwatch"
24+
android:state_checked="true"/>
25+
<item
26+
android:id="@+id/state_off"
27+
android:drawable="@drawable/vd_clock_stopwatch"/>
28+
<transition
29+
android:drawable="@drawable/avd_clock_stopwatch"
30+
android:fromId="@id/state_off"
31+
android:toId="@id/state_on"/>
32+
</animated-selector>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!--
2+
Copyright 2019 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<animated-selector
18+
xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
tools:ignore="NewApi">
21+
<item
22+
android:id="@+id/state_on"
23+
android:drawable="@drawable/vd_clock_timer"
24+
android:state_checked="true"/>
25+
<item
26+
android:id="@+id/state_off"
27+
android:drawable="@drawable/vd_clock_timer"/>
28+
<transition
29+
android:drawable="@drawable/avd_clock_timer"
30+
android:fromId="@id/state_off"
31+
android:toId="@id/state_on"/>
32+
</animated-selector>

0 commit comments

Comments
 (0)