Skip to content

Commit 88ac12b

Browse files
committed
add: shimmer
1 parent 7b1dd6b commit 88ac12b

File tree

5 files changed

+146
-10
lines changed

5 files changed

+146
-10
lines changed

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,31 @@
1414
android:padding="4dp"
1515
tools:listitem="@layout/item_list_anime" />
1616

17-
<ProgressBar
17+
<com.facebook.shimmer.ShimmerFrameLayout
1818
android:id="@+id/progress_bar"
19-
style="?android:attr/progressBarStyle"
20-
android:layout_width="wrap_content"
19+
android:layout_width="match_parent"
2120
android:layout_height="wrap_content"
22-
android:layout_marginStart="8dp"
23-
android:layout_marginTop="8dp"
24-
android:layout_marginEnd="8dp"
25-
android:layout_marginBottom="8dp"
26-
android:visibility="gone"
2721
app:layout_constraintBottom_toBottomOf="parent"
2822
app:layout_constraintEnd_toEndOf="parent"
2923
app:layout_constraintStart_toStartOf="parent"
30-
app:layout_constraintTop_toTopOf="parent" />
24+
app:layout_constraintTop_toTopOf="parent"
25+
app:shimmer_auto_start="true">
26+
27+
<ScrollView
28+
android:layout_width="match_parent"
29+
android:layout_height="wrap_content">
30+
<LinearLayout
31+
android:layout_width="match_parent"
32+
android:layout_height="wrap_content"
33+
android:orientation="vertical">
34+
<include layout="@layout/item_list_placeholder" />
35+
<include layout="@layout/item_list_placeholder" />
36+
<include layout="@layout/item_list_placeholder" />
37+
<include layout="@layout/item_list_placeholder" />
38+
</LinearLayout>
39+
</ScrollView>
40+
41+
</com.facebook.shimmer.ShimmerFrameLayout>
3142

3243
<include
3344
android:id="@+id/view_error"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:orientation="horizontal"
7+
android:paddingHorizontal="8dp"
8+
android:weightSum="2">
9+
10+
<androidx.cardview.widget.CardView
11+
style="@style/CardView.Light"
12+
android:layout_width="match_parent"
13+
android:layout_height="wrap_content"
14+
android:layout_margin="4dp"
15+
android:layout_weight="1"
16+
app:cardCornerRadius="16dp">
17+
18+
<androidx.constraintlayout.widget.ConstraintLayout
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content">
21+
22+
<ImageView
23+
android:id="@+id/iv_item_image"
24+
android:layout_width="0dp"
25+
android:layout_height="300dp"
26+
android:background="#DDDDDD"
27+
android:contentDescription="@string/image_description"
28+
android:scaleType="fitXY"
29+
app:layout_constraintEnd_toEndOf="parent"
30+
app:layout_constraintStart_toStartOf="parent"
31+
app:layout_constraintTop_toTopOf="parent" />
32+
33+
<LinearLayout
34+
android:layout_width="0dp"
35+
android:layout_height="70dp"
36+
android:background="#7F000000"
37+
android:gravity="center"
38+
android:orientation="vertical"
39+
app:layout_constraintBottom_toBottomOf="parent"
40+
app:layout_constraintEnd_toEndOf="parent"
41+
app:layout_constraintStart_toStartOf="parent">
42+
43+
<TextView
44+
android:id="@+id/tv_item_title"
45+
android:layout_width="match_parent"
46+
android:layout_height="wrap_content"
47+
android:layout_marginStart="16dp"
48+
android:layout_marginEnd="16dp"
49+
android:background="#DDDDDD"
50+
android:ellipsize="end"
51+
android:maxLines="2"
52+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
53+
android:textColor="#FFFFFFFF"
54+
app:layout_constraintBottom_toTopOf="@+id/tv_item_subtitle"
55+
app:layout_constraintEnd_toEndOf="parent"
56+
app:layout_constraintStart_toStartOf="parent" />
57+
58+
</LinearLayout>
59+
60+
</androidx.constraintlayout.widget.ConstraintLayout>
61+
62+
</androidx.cardview.widget.CardView>
63+
64+
<androidx.cardview.widget.CardView
65+
style="@style/CardView.Light"
66+
android:layout_width="match_parent"
67+
android:layout_height="wrap_content"
68+
android:layout_margin="4dp"
69+
android:layout_weight="1"
70+
app:cardCornerRadius="16dp">
71+
72+
<androidx.constraintlayout.widget.ConstraintLayout
73+
android:layout_width="match_parent"
74+
android:layout_height="wrap_content">
75+
76+
<ImageView
77+
android:id="@+id/iv_item_image2"
78+
android:layout_width="0dp"
79+
android:layout_height="300dp"
80+
android:background="#DDDDDD"
81+
android:contentDescription="@string/image_description"
82+
android:scaleType="fitXY"
83+
app:layout_constraintEnd_toEndOf="parent"
84+
app:layout_constraintStart_toStartOf="parent"
85+
app:layout_constraintTop_toTopOf="parent" />
86+
87+
<LinearLayout
88+
android:layout_width="0dp"
89+
android:layout_height="70dp"
90+
android:background="#7F000000"
91+
android:gravity="center"
92+
android:orientation="vertical"
93+
app:layout_constraintBottom_toBottomOf="parent"
94+
app:layout_constraintEnd_toEndOf="parent"
95+
app:layout_constraintStart_toStartOf="parent">
96+
97+
<TextView
98+
android:id="@+id/tv_item_title2"
99+
android:layout_width="match_parent"
100+
android:layout_height="wrap_content"
101+
android:layout_marginStart="16dp"
102+
android:layout_marginEnd="16dp"
103+
android:background="#DDDDDD"
104+
android:ellipsize="end"
105+
android:maxLines="2"
106+
android:textAppearance="@style/TextAppearance.AppCompat.Title"
107+
android:textColor="#FFFFFFFF"
108+
app:layout_constraintBottom_toTopOf="@+id/tv_item_subtitle"
109+
app:layout_constraintEnd_toEndOf="parent"
110+
app:layout_constraintStart_toStartOf="parent" />
111+
112+
</LinearLayout>
113+
114+
</androidx.constraintlayout.widget.ConstraintLayout>
115+
116+
</androidx.cardview.widget.CardView>
117+
118+
</LinearLayout>

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
34
android:layout_width="match_parent"
45
android:layout_height="200dp"
56
android:background="?attr/colorPrimary"
67
android:gravity="start|bottom"
78
android:orientation="vertical"
8-
android:padding="24dp">
9+
android:padding="24dp"
10+
tools:ignore="Overdraw">
911

1012
<TextView
1113
android:layout_width="wrap_content"

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ buildscript {
3535

3636
ext.lottie_version = "3.4.2"
3737

38+
ext.shimmer_version = "0.5.0"
39+
3840
repositories {
3941
google()
4042
jcenter()

shared_dependencies.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ dependencies {
2323

2424
// Lottie
2525
implementation "com.airbnb.android:lottie:$lottie_version"
26+
27+
// shimmer
28+
implementation "com.facebook.shimmer:shimmer:$shimmer_version"
2629
}

0 commit comments

Comments
 (0)