Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit ad9bf53

Browse files
authored
Merge pull request #686 from jswong65/add-demo2
[Grid] Add more demos
2 parents b4288f7 + 884a759 commit ad9bf53

File tree

13 files changed

+428
-2
lines changed

13 files changed

+428
-2
lines changed

projects/GridExperiments/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
3636
implementation 'androidx.core:core-ktx:1.3.1'
3737
implementation 'androidx.appcompat:appcompat:1.2.0'
38+
implementation "androidx.cardview:cardview:1.0.0"
3839
implementation 'com.google.android.material:material:1.2.1'
3940
implementation project(path: ':constraintlayout')
4041
implementation 'org.jetbrains:annotations:15.0'
Loading
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
<gradient
5+
android:type="linear"
6+
android:angle="145"
7+
android:startColor="#DCDCDC"
8+
android:endColor="#bcd4e6" />
9+
10+
<stroke
11+
android:width="4dp"
12+
android:color="#cccccc" />
13+
14+
// The corner radius, reduce it to make it more square
15+
<corners android:radius="36dp"/>
16+
17+
// Add your desired padding
18+
<padding
19+
android:left="20dp"
20+
android:top="10dp"
21+
android:right="20dp"
22+
android:bottom="10dp" >
23+
</padding>
24+
</shape>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
5+
<solid android:color="#192734" />
6+
7+
<stroke
8+
android:width="2dp"
9+
android:color="#cccccc" />
10+
11+
// The corner radius, reduce it to make it more square
12+
<corners android:radius="36dp"/>
13+
14+
// Add your desired padding
15+
<padding
16+
android:left="20dp"
17+
android:top="10dp"
18+
android:right="20dp"
19+
android:bottom="10dp" >
20+
</padding>
21+
</shape>
Loading
Loading
Loading
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.cardview.widget.CardView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:card_view="http://schemas.android.com/apk/res-auto"
5+
android:id="@+id/card"
6+
android:layout_width="0dp"
7+
android:layout_height="0dp"
8+
card_view:cardCornerRadius="16dp">
9+
10+
<androidx.constraintlayout.widget.ConstraintLayout
11+
xmlns:app="http://schemas.android.com/apk/res-auto"
12+
android:layout_width="match_parent"
13+
android:layout_height="match_parent"
14+
android:background="#3A3B3C">
15+
16+
<ImageView
17+
android:id="@+id/image"
18+
android:layout_width="0dp"
19+
android:layout_height="0dp"
20+
app:srcCompat="@drawable/cat"
21+
android:scaleType="fitXY"
22+
app:layout_constraintVertical_bias="0"
23+
app:layout_constraintTop_toTopOf="parent"
24+
app:layout_constraintStart_toStartOf="parent"
25+
app:layout_constraintEnd_toEndOf="parent"
26+
app:layout_constraintBottom_toTopOf="@id/text"
27+
/>
28+
29+
<TextView
30+
android:id="@+id/text"
31+
android:layout_width="wrap_content"
32+
android:layout_height="wrap_content"
33+
android:text="Cat"
34+
android:textSize="15sp"
35+
android:textStyle="bold"
36+
android:textColor="@color/white"
37+
app:layout_constraintStart_toStartOf="parent"
38+
app:layout_constraintEnd_toEndOf="parent"
39+
app:layout_constraintBottom_toBottomOf="parent"
40+
app:layout_constraintTop_toBottomOf="@id/image"
41+
/>
42+
</androidx.constraintlayout.widget.ConstraintLayout>
43+
</androidx.cardview.widget.CardView>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.cardview.widget.CardView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:card_view="http://schemas.android.com/apk/res-auto"
5+
android:id="@+id/card"
6+
android:layout_marginLeft="10dp"
7+
android:layout_marginRight="10dp"
8+
android:layout_gravity="center"
9+
android:layout_width="0dp"
10+
android:layout_height="0dp"
11+
card_view:cardCornerRadius="16dp">
12+
13+
<androidx.constraintlayout.widget.ConstraintLayout
14+
xmlns:app="http://schemas.android.com/apk/res-auto"
15+
android:layout_width="match_parent"
16+
android:layout_height="match_parent"
17+
android:background="#3A3B3C">
18+
19+
<ImageView
20+
android:id="@+id/image"
21+
android:layout_width="0dp"
22+
android:layout_height="0dp"
23+
app:srcCompat="@drawable/dog"
24+
android:scaleType="fitXY"
25+
app:layout_constraintVertical_chainStyle="packed"
26+
app:layout_constraintTop_toTopOf="parent"
27+
app:layout_constraintStart_toStartOf="parent"
28+
app:layout_constraintEnd_toEndOf="parent"
29+
app:layout_constraintBottom_toTopOf="@id/text"
30+
/>
31+
32+
<TextView
33+
android:id="@+id/text"
34+
android:layout_width="wrap_content"
35+
android:layout_height="wrap_content"
36+
android:text="Dog"
37+
android:textSize="15sp"
38+
android:textStyle="bold"
39+
android:textColor="@color/white"
40+
app:layout_constraintVertical_chainStyle="packed"
41+
app:layout_constraintStart_toStartOf="parent"
42+
app:layout_constraintEnd_toEndOf="parent"
43+
app:layout_constraintBottom_toBottomOf="parent"
44+
app:layout_constraintTop_toBottomOf="@id/image"
45+
/>
46+
</androidx.constraintlayout.widget.ConstraintLayout>
47+
</androidx.cardview.widget.CardView>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:app="http://schemas.android.com/apk/res-auto"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
tools:context=".MainActivity">
7+
8+
<androidx.constraintlayout.helper.widget.Grid
9+
android:id="@+id/grid"
10+
android:layout_width="match_parent"
11+
android:layout_height="match_parent"
12+
android:layout_margin="20dp"
13+
android:background="@drawable/background"
14+
android:alpha="0.3"
15+
app:constraint_referenced_ids="image_view,name,email,contacts,card1,card2,card3,card4,card5,card6"
16+
app:grid_columns="2"
17+
app:grid_rows="8"
18+
app:grid_verticalGaps="5dp"
19+
app:grid_skips="0:1x2"
20+
app:grid_spans="2:1x2,4:1x2,6:1x2,8:1x2"
21+
app:grid_rowWeights="1,2,2,1,1,2,2,2"
22+
app:grid_orientation="horizontal"/>
23+
24+
<com.google.android.material.imageview.ShapeableImageView
25+
android:id="@+id/image_view"
26+
android:layout_width="wrap_content"
27+
android:layout_height="wrap_content"
28+
android:background="#d4f1f9"
29+
app:shapeAppearanceOverlay="@style/round"
30+
app:srcCompat="@drawable/avatar" />
31+
32+
<TextView
33+
android:id="@+id/name"
34+
android:layout_width="0dp"
35+
android:layout_height="0dp"
36+
android:textSize="30sp"
37+
android:gravity="center"
38+
android:textStyle="bold"
39+
android:textColor="#555555"
40+
android:text="Mike\nTerry" />
41+
42+
<TextView
43+
android:id="@+id/email"
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:textSize="15sp"
47+
android:gravity="center"
48+
android:text="example@mail123.com" />
49+
50+
<TextView
51+
android:id="@+id/contacts"
52+
android:layout_width="0dp"
53+
android:layout_height="0dp"
54+
55+
android:layout_marginLeft="10dp"
56+
android:textSize="15sp"
57+
android:gravity="center_vertical"
58+
android:textStyle="bold"
59+
android:textColor="#555555"
60+
android:text="Top Contacts" />
61+
62+
<include
63+
android:id="@+id/card1"
64+
layout="@layout/profile_card" />
65+
<include
66+
android:id="@+id/card2"
67+
layout="@layout/profile_card" />
68+
<include
69+
android:id="@+id/card3"
70+
layout="@layout/profile_card" />
71+
<include
72+
android:id="@+id/card4"
73+
layout="@layout/profile_card" />
74+
<include
75+
android:id="@+id/card5"
76+
layout="@layout/profile_card" />
77+
<include
78+
android:id="@+id/card6"
79+
layout="@layout/profile_card" />
80+
81+
<Button
82+
android:id="@+id/btn1"
83+
android:layout_width="0dp"
84+
android:layout_height="0dp"
85+
android:textSize="30sp"
86+
android:text="1" />
87+
88+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.cardview.widget.CardView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:card_view="http://schemas.android.com/apk/res-auto"
5+
android:id="@+id/card"
6+
android:layout_margin="10dp"
7+
android:layout_gravity="center"
8+
android:layout_width="0dp"
9+
android:layout_height="0dp"
10+
card_view:cardCornerRadius="16dp">
11+
12+
<androidx.constraintlayout.widget.ConstraintLayout
13+
xmlns:app="http://schemas.android.com/apk/res-auto"
14+
android:layout_width="match_parent"
15+
android:layout_height="match_parent">
16+
17+
<ImageView
18+
android:id="@+id/icon"
19+
android:layout_width="0dp"
20+
android:layout_height="0dp"
21+
android:layout_marginTop="10dp"
22+
app:srcCompat="@drawable/profile_32"
23+
app:layout_constraintVertical_chainStyle="packed"
24+
app:layout_constraintTop_toTopOf="parent"
25+
app:layout_constraintStart_toStartOf="parent"
26+
app:layout_constraintEnd_toEndOf="parent"
27+
app:layout_constraintBottom_toTopOf="@id/text"
28+
/>
29+
30+
<TextView
31+
android:id="@+id/text"
32+
android:layout_width="wrap_content"
33+
android:layout_height="0dp"
34+
android:text="Contact"
35+
android:textSize="15sp"
36+
android:textStyle="bold"
37+
app:layout_constraintVertical_chainStyle="packed"
38+
app:layout_constraintStart_toStartOf="parent"
39+
app:layout_constraintEnd_toEndOf="parent"
40+
app:layout_constraintBottom_toBottomOf="parent"
41+
app:layout_constraintTop_toBottomOf="@id/icon"
42+
/>
43+
</androidx.constraintlayout.widget.ConstraintLayout>
44+
</androidx.cardview.widget.CardView>

0 commit comments

Comments
 (0)