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

[Grid] Add more demos #686

Merged
merged 1 commit into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/GridExperiments/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.cardview:cardview:1.0.0"
implementation 'com.google.android.material:material:1.2.1'
implementation project(path: ':constraintlayout')
implementation 'org.jetbrains:annotations:15.0'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions projects/GridExperiments/app/src/main/res/drawable/background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:type="linear"
android:angle="145"
android:startColor="#DCDCDC"
android:endColor="#bcd4e6" />

<stroke
android:width="4dp"
android:color="#cccccc" />

// The corner radius, reduce it to make it more square
<corners android:radius="36dp"/>

// Add your desired padding
<padding
android:left="20dp"
android:top="10dp"
android:right="20dp"
android:bottom="10dp" >
</padding>
</shape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="#192734" />

<stroke
android:width="2dp"
android:color="#cccccc" />

// The corner radius, reduce it to make it more square
<corners android:radius="36dp"/>

// Add your desired padding
<padding
android:left="20dp"
android:top="10dp"
android:right="20dp"
android:bottom="10dp" >
</padding>
</shape>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions projects/GridExperiments/app/src/main/res/layout/cat_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card"
android:layout_width="0dp"
android:layout_height="0dp"
card_view:cardCornerRadius="16dp">

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3A3B3C">

<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="0dp"
app:srcCompat="@drawable/cat"
android:scaleType="fitXY"
app:layout_constraintVertical_bias="0"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/text"
/>

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cat"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="@color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/image"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
47 changes: 47 additions & 0 deletions projects/GridExperiments/app/src/main/res/layout/dog_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="0dp"
card_view:cardCornerRadius="16dp">

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3A3B3C">

<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="0dp"
app:srcCompat="@drawable/dog"
android:scaleType="fitXY"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/text"
/>

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dog"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="@color/white"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/image"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
88 changes: 88 additions & 0 deletions projects/GridExperiments/app/src/main/res/layout/profile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<androidx.constraintlayout.helper.widget.Grid
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="@drawable/background"
android:alpha="0.3"
app:constraint_referenced_ids="image_view,name,email,contacts,card1,card2,card3,card4,card5,card6"
app:grid_columns="2"
app:grid_rows="8"
app:grid_verticalGaps="5dp"
app:grid_skips="0:1x2"
app:grid_spans="2:1x2,4:1x2,6:1x2,8:1x2"
app:grid_rowWeights="1,2,2,1,1,2,2,2"
app:grid_orientation="horizontal"/>

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#d4f1f9"
app:shapeAppearanceOverlay="@style/round"
app:srcCompat="@drawable/avatar" />

<TextView
android:id="@+id/name"
android:layout_width="0dp"
android:layout_height="0dp"
android:textSize="30sp"
android:gravity="center"
android:textStyle="bold"
android:textColor="#555555"
android:text="Mike\nTerry" />

<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15sp"
android:gravity="center"
android:text="example@mail123.com" />

<TextView
android:id="@+id/contacts"
android:layout_width="0dp"
android:layout_height="0dp"

android:layout_marginLeft="10dp"
android:textSize="15sp"
android:gravity="center_vertical"
android:textStyle="bold"
android:textColor="#555555"
android:text="Top Contacts" />

<include
android:id="@+id/card1"
layout="@layout/profile_card" />
<include
android:id="@+id/card2"
layout="@layout/profile_card" />
<include
android:id="@+id/card3"
layout="@layout/profile_card" />
<include
android:id="@+id/card4"
layout="@layout/profile_card" />
<include
android:id="@+id/card5"
layout="@layout/profile_card" />
<include
android:id="@+id/card6"
layout="@layout/profile_card" />

<Button
android:id="@+id/btn1"
android:layout_width="0dp"
android:layout_height="0dp"
android:textSize="30sp"
android:text="1" />

</androidx.constraintlayout.widget.ConstraintLayout>
44 changes: 44 additions & 0 deletions projects/GridExperiments/app/src/main/res/layout/profile_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card"
android:layout_margin="10dp"
android:layout_gravity="center"
android:layout_width="0dp"
android:layout_height="0dp"
card_view:cardCornerRadius="16dp">

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/icon"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="10dp"
app:srcCompat="@drawable/profile_32"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/text"
/>

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Contact"
android:textSize="15sp"
android:textStyle="bold"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/icon"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
Loading