Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.jetskicli/
29 changes: 0 additions & 29 deletions CanonicalLayouts/README.md

This file was deleted.

15 changes: 15 additions & 0 deletions FlexBox/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
16 changes: 16 additions & 0 deletions FlexBox/.google/packaging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: "Adaptive layouts using FlexBox in Jetpack Compose"
description: "A sample demonstrating how to use the FlexBox API in Jetpack Compose to build flexible, flow-based adaptive apps optimized for all form factors."
status: PUBLISHED
technologies: [Android, JetpackCompose]
categories:
- JetpackComposeLayouts
languages: [Kotlin]
solutions:
- Mobile
- JetpackNavigation
github: android/adaptive-apps-samples
level: INTERMEDIATE
apiRefs:
- android:androidx.compose.Composable
- android:androidx.compose.foundation.layout.FlexBox
license: apache2
8 changes: 8 additions & 0 deletions FlexBox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# FlexBox layout sample

Build flexible, wrapped, and responsive column/row structures that adapt automatically to display dimensions using Jetpack Compose FlexBox layout APIs.

## Features demonstrated
- **Dynamic wrapping:** Content wrapped inside row/column lines as width adapts.
- **Basis and Shrink parameters:** Proportionally distributing space and shrinking elements under tight dimensions.
- **Alignment & gaps:** Configuring custom alignments and gaps between elements dynamically.
1 change: 1 addition & 0 deletions FlexBox/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
75 changes: 75 additions & 0 deletions FlexBox/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.compose.compiler)
}

android {
namespace = "com.example.flexboxsample"
compileSdk = 37
defaultConfig {
applicationId = "com.example.flexboxsample"
minSdk = 24
targetSdk = 37
versionCode = 1
versionName = "1.0"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
compose = true
aidl = false
buildConfig = false
shaders = false
}

packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

kotlin {
jvmToolchain(17)
}

dependencies {
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)

// Core Android dependencies
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)

// Compose
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.foundation.layout)
// Tooling
debugImplementation(libs.androidx.compose.ui.tooling)
// Instrumented tests
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
debugImplementation(libs.androidx.compose.ui.test.manifest)

// Local tests: jUnit, coroutines, Android runner
testImplementation(libs.junit)

// Instrumented tests: jUnit rules and runners
androidTestImplementation(libs.androidx.test.core)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.androidx.test.espresso.core)
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.flexboxsample

import androidx.activity.ComponentActivity
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import org.junit.Before
import org.junit.Rule
import org.junit.Test

/** UI tests for [FlexBoxSample]. */
class FlexBoxSampleTest {

@get:Rule val composeTestRule = createAndroidComposeRule<ComponentActivity>()

@Before
fun setup() {
composeTestRule.setContent { FlexBoxSample() }
}

@Test
fun flexboxExamples_exist() {
composeTestRule.onNodeWithText("FlexBox sample").assertExists()
composeTestRule.onNodeWithText("Example 0: Column direction (center)").assertExists()
}
}
22 changes: 22 additions & 0 deletions FlexBox/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:windowSoftInputMode="adjustResize"
android:theme="@style/Theme.MyApplication">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading
Loading