├── .circleci
└── config.yml
├── .github
├── issue_template.md
└── workflows
│ └── gradle-wrapper-validation.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── assets
├── align-content.gif
├── align-items.gif
├── divider-beginning-middle.png
├── flex-direction.gif
├── flex-wrap.gif
├── flexbox-layoutmanager.gif
├── flexbox-visual.png
├── fluid-grid
│ ├── nexus9-full-width.png
│ ├── nexus9-half.png
│ ├── nexus9-one-fourth.png
│ └── nexus9-three-fourth.png
├── justify-content.gif
├── layout_alignSelf.gif
├── layout_flexBasisPercent.gif
├── layout_flexGrow.gif
├── layout_flexShrink.gif
├── layout_maxWidth.gif
├── layout_minWidth.gif
├── layout_order.gif
├── layout_wrapBefore.gif
└── pngs
│ └── check_green_small.png
├── build.gradle
├── demo-cat-gallery
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── google
│ │ └── android
│ │ └── flexbox
│ │ └── apps
│ │ └── catgallery
│ │ ├── CatAdapter.kt
│ │ ├── CatViewHolder.kt
│ │ └── MainActivity.kt
│ └── res
│ ├── drawable
│ ├── cat_1.jpg
│ ├── cat_10.jpg
│ ├── cat_11.jpg
│ ├── cat_12.jpg
│ ├── cat_13.jpg
│ ├── cat_14.jpg
│ ├── cat_15.jpg
│ ├── cat_16.jpg
│ ├── cat_17.jpg
│ ├── cat_18.jpg
│ ├── cat_19.jpg
│ ├── cat_2.jpg
│ ├── cat_3.jpg
│ ├── cat_4.jpg
│ ├── cat_5.jpg
│ ├── cat_6.jpg
│ ├── cat_7.jpg
│ ├── cat_8.jpg
│ └── cat_9.jpg
│ ├── layout
│ ├── activity_main.xml
│ ├── content_main.xml
│ └── viewholder_cat.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── demo-playground
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── google
│ │ └── android
│ │ └── apps
│ │ └── flexbox
│ │ └── test
│ │ └── MainActivityTest.kt
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── google
│ │ └── android
│ │ └── flexbox
│ │ ├── Extensions.kt
│ │ ├── FlexItemAdapter.kt
│ │ ├── FlexItemChangedListener.kt
│ │ ├── FlexItemChangedListenerImpl.kt
│ │ ├── FlexItemChangedListenerImplRecyclerView.kt
│ │ ├── FlexItemClickListener.kt
│ │ ├── FlexItemEditFragment.kt
│ │ ├── FlexItemViewHolder.kt
│ │ ├── FlexboxLayoutFragment.kt
│ │ ├── FragmentHelper.kt
│ │ ├── MainActivity.kt
│ │ ├── RecyclerViewFragment.kt
│ │ ├── SettingsActivity.kt
│ │ └── validators
│ │ ├── DimensionInputValidator.kt
│ │ ├── FixedDimensionInputValidator.kt
│ │ ├── FlexBasisPercentInputValidator.kt
│ │ ├── InputValidator.kt
│ │ ├── IntegerInputValidator.kt
│ │ └── NonNegativeDecimalInputValidator.kt
│ └── res
│ ├── drawable-hdpi
│ ├── ic_add_white_24dp.png
│ └── ic_remove_white_24dp.png
│ ├── drawable-mdpi
│ ├── ic_add_white_24dp.png
│ └── ic_remove_white_24dp.png
│ ├── drawable-xhdpi
│ ├── ic_add_white_24dp.png
│ └── ic_remove_white_24dp.png
│ ├── drawable-xxhdpi
│ ├── ic_add_white_24dp.png
│ └── ic_remove_white_24dp.png
│ ├── drawable-xxxhdpi
│ ├── ic_add_white_24dp.png
│ └── ic_remove_white_24dp.png
│ ├── drawable
│ ├── flex_item_background.xml
│ └── side_nav_bar.xml
│ ├── layout
│ ├── activity_main.xml
│ ├── app_bar_main.xml
│ ├── content_main.xml
│ ├── fragment_flex_item_edit.xml
│ ├── fragment_flexboxlayout.xml
│ ├── fragment_recyclerview.xml
│ ├── nav_header_main.xml
│ ├── spinner_align_content.xml
│ ├── spinner_align_items.xml
│ ├── spinner_flex_direction.xml
│ ├── spinner_flex_wrap.xml
│ ├── spinner_item.xml
│ ├── spinner_justify_content.xml
│ └── viewholder_flex_item.xml
│ ├── menu
│ ├── activity_main_drawer.xml
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v14
│ └── styles.xml
│ ├── values-v21
│ └── styles.xml
│ ├── values-w720dp
│ └── dimens.xml
│ ├── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── new_flex_item_preferences.xml
├── flexbox
├── .gitignore
├── build.gradle
├── constants.gradle
├── maven-puglisher-plugin.gradle
├── proguard-rules.txt
└── src
│ ├── androidTest
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── google
│ │ │ └── android
│ │ │ └── flexbox
│ │ │ ├── FakeFlexContainer.kt
│ │ │ ├── FlexboxHelperTest.kt
│ │ │ └── test
│ │ │ ├── ConfigChangeActivity.kt
│ │ │ ├── FlexboxAndroidTest.kt
│ │ │ ├── FlexboxLayoutManagerConfigChangeTest.kt
│ │ │ ├── FlexboxLayoutManagerTest.kt
│ │ │ ├── FlexboxTestActivity.kt
│ │ │ ├── IsEqualAllowingError.kt
│ │ │ ├── NestedInnerAdapter.kt
│ │ │ ├── NestedOuterAdapter.kt
│ │ │ ├── TestAdapter.kt
│ │ │ ├── TestAdapterMultiViewTypes.kt
│ │ │ ├── TestUtil.kt
│ │ │ └── TestViewHolder.kt
│ └── res
│ │ ├── drawable
│ │ ├── divider.xml
│ │ ├── divider_thick.xml
│ │ └── flex_item_background.xml
│ │ ├── layout
│ │ ├── activity_align_content_test.xml
│ │ ├── activity_align_content_test_overflowed.xml
│ │ ├── activity_align_items_baseline_test.xml
│ │ ├── activity_align_items_baseline_wrap_content.xml
│ │ ├── activity_align_items_parent_padding_test.xml
│ │ ├── activity_align_items_test.xml
│ │ ├── activity_align_self_stretch_test.xml
│ │ ├── activity_child_needs_remeasure_column.xml
│ │ ├── activity_child_needs_remeasure_row.xml
│ │ ├── activity_direction_column_align_items_center_margin_oneside.xml
│ │ ├── activity_direction_row_align_items_center_margin_oneside.xml
│ │ ├── activity_divider_test_direction_column.xml
│ │ ├── activity_divider_test_direction_row.xml
│ │ ├── activity_empty_children.xml
│ │ ├── activity_first_item_large_horizontal_test.xml
│ │ ├── activity_first_item_large_vertical_test.xml
│ │ ├── activity_first_view_gone_first_line_single_item.xml
│ │ ├── activity_first_view_gone_layout_grow_set_for_rest.xml
│ │ ├── activity_first_view_gone_layout_shrink_set_for_rest.xml
│ │ ├── activity_flex_basis_percent_test.xml
│ │ ├── activity_flex_grow_test.xml
│ │ ├── activity_flex_item_match_parent.xml
│ │ ├── activity_flex_item_match_parent_direction_column.xml
│ │ ├── activity_flex_wrap_test.xml
│ │ ├── activity_flexbox_wrap_content.xml
│ │ ├── activity_flexbox_wrapped_with_horizontalscrollview.xml
│ │ ├── activity_flexbox_wrapped_with_scrollview.xml
│ │ ├── activity_justify_content_test.xml
│ │ ├── activity_justify_content_with_gone.xml
│ │ ├── activity_justify_content_with_parent_padding.xml
│ │ ├── activity_maxheight_test.xml
│ │ ├── activity_maxheight_upper_bound_test.xml
│ │ ├── activity_maxwidth_test.xml
│ │ ├── activity_maxwidth_upper_bound_test.xml
│ │ ├── activity_minheight_lower_bound_test.xml
│ │ ├── activity_minheight_test.xml
│ │ ├── activity_minwidth_lower_bound_test.xml
│ │ ├── activity_minwidth_test.xml
│ │ ├── activity_order_test.xml
│ │ ├── activity_simple.xml
│ │ ├── activity_stretch_test.xml
│ │ ├── activity_views_visibility_gone.xml
│ │ ├── activity_views_visibility_invisible.xml
│ │ ├── activity_visibility_gone_first_item_in_flex_line_column.xml
│ │ ├── activity_visibility_gone_first_item_in_flex_line_row.xml
│ │ ├── activity_wrap_before_test.xml
│ │ ├── activity_wrap_child_margin_horizontal_test.xml
│ │ ├── activity_wrap_child_margin_vertical_test.xml
│ │ ├── activity_wrap_content_child_bottom_margin_column_grow.xml
│ │ ├── activity_wrap_content_child_bottom_margin_column_shrink.xml
│ │ ├── activity_wrap_content_child_bottom_margin_row_grow.xml
│ │ ├── activity_wrap_content_child_bottom_margin_row_shrink.xml
│ │ ├── activity_wrap_parent_padding_horizontal_test.xml
│ │ ├── activity_wrap_parent_padding_vertical_test.xml
│ │ ├── activity_zero_height_positive_flexgrow.xml
│ │ ├── activity_zero_width_positive_flexgrow.xml
│ │ ├── recyclerview.xml
│ │ ├── recyclerview_reverse.xml
│ │ ├── recyclerview_viewholder.xml
│ │ ├── viewholder_inner_recyclerview.xml
│ │ ├── viewholder_inner_recyclerview_wrap_horizontally.xml
│ │ ├── viewholder_textview.xml
│ │ ├── wrapped_recyclerview.xml
│ │ └── wrapped_recyclerview_scroll_vertical.xml
│ │ └── values
│ │ └── strings.xml
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── google
│ │ └── android
│ │ └── flexbox
│ │ ├── AlignContent.java
│ │ ├── AlignItems.java
│ │ ├── AlignSelf.java
│ │ ├── FlexContainer.java
│ │ ├── FlexDirection.java
│ │ ├── FlexItem.java
│ │ ├── FlexLine.java
│ │ ├── FlexWrap.java
│ │ ├── FlexboxHelper.java
│ │ ├── FlexboxItemDecoration.java
│ │ ├── FlexboxLayout.java
│ │ ├── FlexboxLayoutManager.java
│ │ └── JustifyContent.java
│ └── res
│ └── values
│ └── attrs.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── tool
└── codeStyleSettings.xml
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | working_directory: ~/code
5 | docker:
6 | - image: circleci/android:api-29
7 | environment:
8 | JVM_OPTS: -Xmx3200m
9 | MAX_RETRY: 4
10 | steps:
11 | - checkout
12 | - restore_cache:
13 | key: jars-{{ checksum "build.gradle" }}-{{ checksum "flexbox/build.gradle" }}
14 | - run:
15 | name: Download Dependencies
16 | command: ./gradlew androidDependencies
17 | - run:
18 | name: Set up gcloud service key
19 | command: |
20 | if [ -n "$GCLOUD_SERVICE_KEY" ]; then echo ${GCLOUD_SERVICE_KEY} | base64 --decode > ${HOME}/client-secret.json ;
21 | gcloud config set project ${GCLOUD_PROJECT} ;
22 | gcloud auth activate-service-account ${GCLOUD_SERVICE_ACCOUNT} --key-file ${HOME}/client-secret.json ;
23 | fi
24 | - save_cache:
25 | paths:
26 | - ~/.gradle
27 | key: jars-{{ checksum "build.gradle" }}-{{ checksum "flexbox/build.gradle" }}
28 | - run:
29 | name: Build apks
30 | command: ./gradlew build assembleAndroidTest
31 | - run:
32 | name: Run Firebase Test Lab
33 | command: |
34 | if [ -n "$GCLOUD_SERVICE_KEY" ]; then set +e ;
35 | counter=0 ;
36 | result=1 ;
37 | while [ $result != 0 -a $counter -lt $MAX_RETRY ]; do
38 | gcloud firebase test android run \
39 | --type instrumentation \
40 | --app demo-playground/build/outputs/apk/debug/demo-playground-debug.apk \
41 | --test flexbox/build/outputs/apk/androidTest/debug/flexbox-debug-androidTest.apk \
42 | --device-ids hammerhead,sailfish \
43 | --os-version-ids 19,21,23,24,25,26 \
44 | --locales en --orientations portrait,landscape \
45 | --results-bucket android-devrel-ci-flexbox \
46 | --timeout 180s ;
47 | result=$? ;
48 | let counter=counter+1 ;
49 | done
50 | exit $result ;
51 | fi
52 |
--------------------------------------------------------------------------------
/.github/issue_template.md:
--------------------------------------------------------------------------------
1 | - [ ] I have searched [existing issues](https://github.com/google/flexbox-layout/issues) and confirmed this is not a duplicate
2 |
3 | ## Issues and steps to reproduce
4 | *Please replace this with steps to reproduce your issue.*
5 |
6 | ## Expected behavior
7 | *Please describe what you expected would happen.*
8 |
9 | ## Version of the flexbox library
10 | *e.g. 0.2.6, 0.3.0-alpha3*
11 |
12 | ## Link to code
13 | *Please link to the code we can use to reproduce this issue.*
14 | *A complete project we can build/run is preferred, if you can't provide one, please show*
15 | *us relevant code*
16 |
--------------------------------------------------------------------------------
/.github/workflows/gradle-wrapper-validation.yml:
--------------------------------------------------------------------------------
1 | name: "Validate Gradle Wrapper"
2 | on: [push, pull_request]
3 |
4 | jobs:
5 | validation:
6 | name: "Validation"
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v2
10 | - uses: gradle/wrapper-validation-action@v1
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea/
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | !.idea/codeStyleSettings.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .vscode/
12 |
13 | # Taken from Android.gitignore https://github.com/github/gitignore/blob/master/Android.gitignore
14 | #
15 | # Built application files
16 | *.apk
17 | *.ap_
18 |
19 | # Files for the Dalvik VM
20 | *.dex
21 |
22 | # Java class files
23 | *.class
24 |
25 | # Generated files
26 | bin/
27 | gen/
28 | out/
29 |
30 | # Gradle files
31 | .gradle/
32 | build/
33 |
34 | # Local configuration file (sdk path, etc)
35 | local.properties
36 |
37 | # Proguard folder generated by Eclipse
38 | proguard/
39 |
40 | # Log Files
41 | *.log
42 |
43 | # Android Studio Navigation editor temp files
44 | .navigation/
45 |
46 | # Android Studio captures folder
47 | captures/
48 |
49 | # Intellij
50 | *.iml
51 |
--------------------------------------------------------------------------------
/assets/align-content.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/align-content.gif
--------------------------------------------------------------------------------
/assets/align-items.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/align-items.gif
--------------------------------------------------------------------------------
/assets/divider-beginning-middle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/divider-beginning-middle.png
--------------------------------------------------------------------------------
/assets/flex-direction.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/flex-direction.gif
--------------------------------------------------------------------------------
/assets/flex-wrap.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/flex-wrap.gif
--------------------------------------------------------------------------------
/assets/flexbox-layoutmanager.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/flexbox-layoutmanager.gif
--------------------------------------------------------------------------------
/assets/flexbox-visual.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/flexbox-visual.png
--------------------------------------------------------------------------------
/assets/fluid-grid/nexus9-full-width.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/fluid-grid/nexus9-full-width.png
--------------------------------------------------------------------------------
/assets/fluid-grid/nexus9-half.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/fluid-grid/nexus9-half.png
--------------------------------------------------------------------------------
/assets/fluid-grid/nexus9-one-fourth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/fluid-grid/nexus9-one-fourth.png
--------------------------------------------------------------------------------
/assets/fluid-grid/nexus9-three-fourth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/fluid-grid/nexus9-three-fourth.png
--------------------------------------------------------------------------------
/assets/justify-content.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/justify-content.gif
--------------------------------------------------------------------------------
/assets/layout_alignSelf.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_alignSelf.gif
--------------------------------------------------------------------------------
/assets/layout_flexBasisPercent.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_flexBasisPercent.gif
--------------------------------------------------------------------------------
/assets/layout_flexGrow.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_flexGrow.gif
--------------------------------------------------------------------------------
/assets/layout_flexShrink.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_flexShrink.gif
--------------------------------------------------------------------------------
/assets/layout_maxWidth.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_maxWidth.gif
--------------------------------------------------------------------------------
/assets/layout_minWidth.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_minWidth.gif
--------------------------------------------------------------------------------
/assets/layout_order.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_order.gif
--------------------------------------------------------------------------------
/assets/layout_wrapBefore.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/layout_wrapBefore.gif
--------------------------------------------------------------------------------
/assets/pngs/check_green_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/assets/pngs/check_green_small.png
--------------------------------------------------------------------------------
/demo-cat-gallery/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 | apply plugin: 'com.android.application'
18 | apply plugin: 'kotlin-android'
19 |
20 | android {
21 | compileSdkVersion rootProject.ext.compileSdkVersion
22 |
23 | defaultConfig {
24 | applicationId "com.google.android.flexbox.apps.catgallery"
25 | minSdkVersion rootProject.ext.minSdkVersion
26 | targetSdkVersion rootProject.ext.targetSdkVersion
27 | versionCode 1
28 | versionName "1.0"
29 |
30 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
31 | }
32 | buildTypes {
33 | release {
34 | shrinkResources true
35 | minifyEnabled true
36 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
37 | }
38 | }
39 | }
40 |
41 | dependencies {
42 | implementation project(path: ":flexbox")
43 | implementation "androidx.appcompat:appcompat:${rootProject.androidxAppCompatVersion}"
44 | implementation "androidx.recyclerview:recyclerview:${rootProject.androidxRecyclerViewVersion}"
45 | implementation "com.google.android.material:material:${rootProject.materialVersion}"
46 | implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.kotlinVersion}"
47 | }
48 |
--------------------------------------------------------------------------------
/demo-cat-gallery/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/google/home/thagikura/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/java/com/google/android/flexbox/apps/catgallery/CatViewHolder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.apps.catgallery
18 |
19 | import android.view.View
20 | import android.widget.ImageView
21 | import androidx.annotation.DrawableRes
22 | import androidx.recyclerview.widget.RecyclerView
23 | import com.google.android.flexbox.FlexboxLayoutManager
24 |
25 | /**
26 | * ViewHolder that represents a cat image.
27 | */
28 | internal class CatViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
29 |
30 | private val imageView: ImageView = itemView.findViewById(R.id.imageview)
31 |
32 | internal fun bindTo(@DrawableRes drawableRes: Int) {
33 | imageView.setImageResource(drawableRes)
34 | val lp = imageView.layoutParams
35 | if (lp is FlexboxLayoutManager.LayoutParams) {
36 | lp.flexGrow = 1f
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_1.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_10.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_10.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_11.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_12.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_13.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_13.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_14.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_14.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_15.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_15.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_16.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_16.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_17.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_17.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_18.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_18.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_19.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_19.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_2.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_3.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_4.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_5.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_6.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_7.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_8.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_8.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/drawable/cat_9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/drawable/cat_9.jpg
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/layout/viewholder_cat.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-cat-gallery/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 | #3F51B5
18 | #303F9F
19 | #FF4081
20 |
21 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 | 180dp
18 |
19 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 | Cat Gallery
18 | Cat image
19 |
20 |
--------------------------------------------------------------------------------
/demo-cat-gallery/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
25 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/demo-playground/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2016 Google Inc. All rights reserved.
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 | # Add project specific ProGuard rules here.
18 | # By default, the flags in this file are appended to flags specified
19 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
20 | # You can edit the include path and order by changing the proguardFiles
21 | # directive in build.gradle.
22 | #
23 | # For more details, see
24 | # http://developer.android.com/guide/developing/tools/proguard.html
25 |
26 | # Add any project specific keep options here:
27 |
28 | # If your project uses WebView with JS, uncomment the following
29 | # and specify the fully qualified class name to the JavaScript interface
30 | # class:
31 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
32 | # public *;
33 | #}
34 |
--------------------------------------------------------------------------------
/demo-playground/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
16 |
19 |
20 |
21 |
22 |
28 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/Extensions.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox
18 |
19 | import android.content.Context
20 |
21 | /**
22 | * Convert pixel to dp. Preserve the negative value as it's used for representing
23 | * MATCH_PARENT(-1) and WRAP_CONTENT(-2).
24 | * Ignore the round error that might happen in dividing the pixel by the density.
25 | *
26 | * @param pixel the value in pixel
27 | *
28 | * @return the converted value in dp
29 | */
30 | fun Context.pixelToDp(pixel: Int): Int {
31 | val displayMetrics = this.resources.displayMetrics
32 | return if (pixel < 0) pixel else Math.round(pixel / displayMetrics.density)
33 | }
34 |
35 | /**
36 | * Convert dp to pixel. Preserve the negative value as it's used for representing
37 | * MATCH_PARENT(-1) and WRAP_CONTENT(-2).
38 | *
39 | * @param dp the value in dp
40 | *
41 | * @return the converted value in pixel
42 | */
43 | fun Context.dpToPixel(dp: Int): Int {
44 | val displayMetrics = this.resources.displayMetrics
45 | return if (dp < 0) dp else Math.round(dp * displayMetrics.density)
46 | }
47 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/FlexItemChangedListener.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox
18 |
19 | /**
20 | * A listener that listens to the change of a flex item
21 | */
22 | internal interface FlexItemChangedListener {
23 |
24 | fun onFlexItemChanged(flexItem: FlexItem, viewIndex: Int)
25 | }
26 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/FlexItemChangedListenerImpl.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox
18 |
19 | import android.view.ViewGroup
20 |
21 | /**
22 | * Default implementation for the [FlexItemChangedListener].
23 | */
24 | internal class FlexItemChangedListenerImpl(private val flexContainer: FlexContainer) : FlexItemChangedListener {
25 |
26 | override fun onFlexItemChanged(flexItem: FlexItem, viewIndex: Int) {
27 | val view = flexContainer.getFlexItemAt(viewIndex)
28 | view.layoutParams = flexItem as ViewGroup.LayoutParams
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/FlexItemChangedListenerImplRecyclerView.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox
18 |
19 | import android.view.ViewGroup
20 | import androidx.recyclerview.widget.RecyclerView
21 |
22 | /**
23 | * Implementation for the [FlexItemChangedListener].
24 | * It expects RecyclerView as the underlying flex container implementation.
25 | */
26 | internal class FlexItemChangedListenerImplRecyclerView(private val flexContainer: FlexContainer,
27 | private val adapter: RecyclerView.Adapter<*>) : FlexItemChangedListener {
28 |
29 | override fun onFlexItemChanged(flexItem: FlexItem, viewIndex: Int) {
30 | val view = flexContainer.getFlexItemAt(viewIndex)
31 | view.layoutParams = flexItem as ViewGroup.LayoutParams
32 | adapter.notifyDataSetChanged()
33 | // TODO: An Exception is thrown if notifyItemChanged(int) is used.
34 | // Investigate that, but using LinearLayoutManager also produces the same Exception
35 | // java.lang.IllegalArgumentException: Called attach on a child which is not detached:
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/FlexItemClickListener.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox
18 |
19 | import android.view.View
20 | import androidx.appcompat.app.AppCompatActivity
21 |
22 | /**
23 | * Implementation of the [android.view.View.OnClickListener] when a flex item is clicked in
24 | * the Flexbox Playground demo app.
25 | */
26 | internal class FlexItemClickListener(private val activity: AppCompatActivity, private val flexItemChangedListener: FlexItemChangedListener,
27 | private val viewIndex: Int) : View.OnClickListener {
28 |
29 | override fun onClick(v: View) =
30 | FlexItemEditFragment.newInstance(v.layoutParams as FlexItem, viewIndex).apply {
31 | setFlexItemChangedListener(flexItemChangedListener)
32 | }.show(activity.supportFragmentManager, EDIT_DIALOG_TAG)
33 |
34 | companion object {
35 |
36 | private const val EDIT_DIALOG_TAG = "edit_dialog_tag"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/FlexItemViewHolder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox
18 |
19 | import android.view.Gravity
20 | import android.view.View
21 | import android.widget.TextView
22 | import androidx.recyclerview.widget.RecyclerView
23 | import com.google.android.apps.flexbox.R
24 |
25 | /**
26 | * ViewHolder implementation for a flex item.
27 | */
28 | class FlexItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
29 |
30 | private val textView: TextView = itemView.findViewById(R.id.textview)
31 |
32 | fun bindTo(params: RecyclerView.LayoutParams) {
33 | val adapterPosition = adapterPosition
34 | textView.apply {
35 | text = (adapterPosition + 1).toString()
36 | setBackgroundResource(R.drawable.flex_item_background)
37 | gravity = Gravity.CENTER
38 | layoutParams = params
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/validators/DimensionInputValidator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.validators
18 |
19 | import android.text.TextUtils
20 |
21 | /**
22 | * Validator for dimension values including match_parent and wrap_content.
23 | */
24 | class DimensionInputValidator : InputValidator {
25 |
26 | override fun isValidInput(charSequence: CharSequence): Boolean {
27 | // -1 represents match_parent, -2 represents wrap_content
28 | return !charSequence.isEmpty() && (TextUtils.isDigitsOnly(charSequence) ||
29 | charSequence.toString() == "-1" ||
30 | charSequence.toString() == "-2")
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/validators/FixedDimensionInputValidator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.validators
18 |
19 | import android.text.TextUtils
20 |
21 | /**
22 | * Validator for dimension values.
23 | */
24 | class FixedDimensionInputValidator : InputValidator {
25 |
26 | override fun isValidInput(charSequence: CharSequence): Boolean {
27 | return !charSequence.isEmpty() && TextUtils.isDigitsOnly(charSequence)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/validators/FlexBasisPercentInputValidator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.validators
18 |
19 | import android.text.TextUtils
20 |
21 | /**
22 | * Validator for the flex basis percent attribute.
23 | */
24 | class FlexBasisPercentInputValidator : InputValidator {
25 |
26 | override fun isValidInput(charSequence: CharSequence): Boolean {
27 | // -1 represents not set
28 | return !charSequence.isEmpty() && (TextUtils.isDigitsOnly(charSequence) || charSequence.toString() == "-1")
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/validators/InputValidator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.validators
18 |
19 | /**
20 | * Interface to verify a given input.
21 | */
22 | interface InputValidator {
23 |
24 | /**
25 | * Verifies if the given input is valid.
26 |
27 | * @param charSequence the input to be verified
28 | * *
29 | * @return `true` if charSequence is valid, `false` otherwise
30 | */
31 | fun isValidInput(charSequence: CharSequence): Boolean
32 | }
33 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/validators/IntegerInputValidator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.validators
18 |
19 | /**
20 | * Validator for the integers.
21 | */
22 | class IntegerInputValidator : InputValidator {
23 |
24 | override fun isValidInput(charSequence: CharSequence): Boolean {
25 | return charSequence.toString().toIntOrNull() != null
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/demo-playground/src/main/java/com/google/android/flexbox/validators/NonNegativeDecimalInputValidator.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.validators
18 |
19 | /**
20 | * Validator for non negative integers.
21 | */
22 | class NonNegativeDecimalInputValidator : InputValidator {
23 |
24 | override fun isValidInput(charSequence: CharSequence): Boolean {
25 | return charSequence.toString().toFloatOrNull() ?: -1f >= 0
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-hdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-hdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-hdpi/ic_remove_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-hdpi/ic_remove_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-mdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-mdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-mdpi/ic_remove_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-mdpi/ic_remove_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-xhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-xhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-xhdpi/ic_remove_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-xhdpi/ic_remove_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-xxhdpi/ic_remove_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-xxhdpi/ic_remove_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable-xxxhdpi/ic_remove_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/drawable-xxxhdpi/ic_remove_white_24dp.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable/flex_item_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
19 |
25 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
29 |
30 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/fragment_flexboxlayout.xml:
--------------------------------------------------------------------------------
1 |
16 |
26 |
27 |
33 |
34 |
40 |
41 |
47 |
48 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/fragment_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
16 |
20 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/spinner_align_content.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/spinner_align_items.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/spinner_flex_direction.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/spinner_flex_wrap.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/spinner_item.xml:
--------------------------------------------------------------------------------
1 |
16 |
28 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/spinner_justify_content.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/layout/viewholder_flex_item.xml:
--------------------------------------------------------------------------------
1 |
16 |
20 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
16 |
41 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
26 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/demo-playground/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo-playground/src/main/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
26 |
27 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/values-w720dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 64dp
19 | 64dp
20 |
21 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 | #3F51B5
18 | #303F9F
19 | #FF4081
20 | #FFCEE1
21 |
22 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 16dp
19 | 160dp
20 |
21 |
22 | 16dp
23 | 16dp
24 | 16dp
25 | 92dp
26 |
27 | 4dp
28 | 8dp
29 | 16dp
30 | 32dp
31 | 64dp
32 |
33 | 80dp
34 | 120dp
35 | 160dp
36 |
37 |
--------------------------------------------------------------------------------
/demo-playground/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
24 |
25 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/flexbox/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/flexbox/constants.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 | ext {
18 | projectName = 'flexbox-layout'
19 | projectDesc = 'Flexbox for Android'
20 |
21 | githubUrl = 'https://github.com/google/flexbox-layout'
22 |
23 | mavenGroup = 'com.google.android.flexbox'
24 | mavenArtifactId = 'flexbox'
25 | mavenVersion = '3.0.0'
26 |
27 | bintrayOrg = 'google'
28 | }
29 |
--------------------------------------------------------------------------------
/flexbox/maven-puglisher-plugin.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 Google Inc. All rights reserved.
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 | apply plugin: 'maven-publish'
18 | apply from: 'constants.gradle'
19 |
20 | afterEvaluate {
21 |
22 | publishing {
23 | publications {
24 | release(MavenPublication) {
25 | from components.release
26 |
27 | groupId = "$mavenGroup"
28 | artifactId = "$mavenArtifactId"
29 | version = "$mavenVersion"
30 |
31 | artifact androidSourcesJar
32 |
33 | pom {
34 | name = "$projectName"
35 | description = "$projectDesc"
36 | licenses {
37 | license {
38 | name = 'The Apache Software License, Version 2.0'
39 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
40 | distribution = 'repo'
41 | }
42 | }
43 | developers {
44 | developer {
45 | name = 'Google'
46 | }
47 | }
48 | scm {
49 | connection = "${githubUrl}.git"
50 | url = githubUrl
51 | }
52 | }
53 | }
54 | }
55 | }
56 | }
57 |
58 | task androidSourcesJar(type: Jar) {
59 | archiveClassifier.set('sources')
60 | from android.sourceSets.main.java.srcDirs
61 | }
--------------------------------------------------------------------------------
/flexbox/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2016 Google Inc. All rights reserved.
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 | # The FlexboxLayoutManager may be set from a layout xml, in that situation the RecyclerView
18 | # tries to instantiate the layout manager using reflection.
19 | # This is to prevent the layout manager from being obfuscated.
20 | -keepnames public class com.google.android.flexbox.FlexboxLayoutManager
--------------------------------------------------------------------------------
/flexbox/src/androidTest/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
21 |
22 |
23 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/java/com/google/android/flexbox/test/ConfigChangeActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.test
18 |
19 | import android.app.Activity
20 | import android.content.res.Configuration
21 | import android.util.Log
22 |
23 | import com.google.android.flexbox.FlexboxLayout
24 |
25 | /**
26 | * Activity for testing the [FlexboxLayout] that handles configuration changes by itself
27 | * instead of letting the system take care of those.
28 | */
29 | class ConfigChangeActivity : Activity() {
30 | override fun onConfigurationChanged(newConfig: Configuration) {
31 | super.onConfigurationChanged(newConfig)
32 |
33 | Log.d(TAG, "onConfigurationChanged: $newConfig")
34 | }
35 |
36 | companion object {
37 | private const val TAG = "ConfigChangeActivity"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/java/com/google/android/flexbox/test/FlexboxTestActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox.test
18 |
19 | import android.app.Activity
20 | import com.google.android.flexbox.FlexboxLayout
21 |
22 | /**
23 | * Activity for testing the [FlexboxLayout].
24 | */
25 | class FlexboxTestActivity : Activity()
26 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/java/com/google/android/flexbox/test/IsEqualAllowingError.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox.test
18 |
19 | import org.hamcrest.BaseMatcher
20 | import org.hamcrest.Description
21 | import org.hamcrest.Factory
22 | import org.hamcrest.Matcher
23 | import java.util.*
24 |
25 | /**
26 | * Custom [BaseMatcher] that expects [Number] value allowing some errors to allow
27 | * such as rounding errors.
28 | */
29 | class IsEqualAllowingError private constructor(private val expected: Number, private val errorAllowed: Int) : BaseMatcher() {
30 |
31 | override fun matches(item: Any): Boolean {
32 | if (item !is Number) {
33 | return false
34 | }
35 | return expected.toInt() - errorAllowed <= item.toInt() && item.toInt() <= expected.toInt() + errorAllowed
36 | }
37 |
38 | override fun describeTo(description: Description) {
39 | description.appendText(
40 | String.format(Locale.US, "expected value is <%s> allowing error of <%s>.", expected,
41 | errorAllowed))
42 | }
43 |
44 | companion object {
45 |
46 | @Factory
47 | fun isEqualAllowingError(expected: T): Matcher {
48 | return IsEqualAllowingError(expected, 2)
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/java/com/google/android/flexbox/test/NestedInnerAdapter.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Google Inc. All rights reserved.
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 com.google.android.flexbox.test
18 |
19 | import android.view.LayoutInflater
20 | import android.view.View
21 | import android.view.ViewGroup
22 | import android.widget.TextView
23 | import androidx.recyclerview.widget.RecyclerView
24 |
25 | /**
26 | * Adapter for the tests for nested RecyclerViews.
27 | * This Adapter is used for the inner RecyclerView.
28 | */
29 | internal class NestedInnerAdapter(private val innerPosition: Int, private val itemCount: Int)
30 | : RecyclerView.Adapter() {
31 |
32 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NestedInnerAdapter.InnerViewHolder {
33 | val view = LayoutInflater.from(parent.context).inflate(R.layout.viewholder_textview, parent, false)
34 | return InnerViewHolder(view)
35 | }
36 |
37 | override fun onBindViewHolder(holder: InnerViewHolder, position: Int) {
38 | holder.textView.text = holder.textView.resources.getString(R.string.item_description, innerPosition, position)
39 | }
40 |
41 | override fun getItemCount() = itemCount
42 |
43 | internal class InnerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
44 |
45 | val textView: TextView = itemView.findViewById(R.id.textview)
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/java/com/google/android/flexbox/test/TestUtil.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox.test
18 |
19 | import android.content.Context
20 |
21 | internal fun Context.dpToPixel(dp: Int): Int {
22 | val displayMetrics = this.resources.displayMetrics
23 | return if (dp < 0) dp else Math.round(dp * displayMetrics.density)
24 | }
25 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/java/com/google/android/flexbox/test/TestViewHolder.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox.test
18 |
19 | import android.view.View
20 | import android.widget.TextView
21 | import androidx.recyclerview.widget.RecyclerView
22 |
23 | /**
24 | * ViewHolder implementation for a flex item for testing.
25 | */
26 | internal class TestViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
27 | val textView: TextView = itemView.findViewById(R.id.textview)
28 | }
29 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/drawable/divider.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
21 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/drawable/divider_thick.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
20 |
21 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/drawable/flex_item_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_align_content_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
30 |
31 |
36 |
37 |
42 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_align_items_baseline_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
31 |
32 |
38 |
39 |
46 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_align_items_baseline_wrap_content.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
31 |
32 |
38 |
39 |
46 |
47 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_align_items_parent_padding_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_align_items_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_align_self_stretch_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
32 |
33 |
38 |
39 |
44 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_child_needs_remeasure_column.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
31 |
32 |
38 |
39 |
44 |
45 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_child_needs_remeasure_row.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
31 |
32 |
38 |
39 |
44 |
45 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_direction_column_align_items_center_margin_oneside.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
31 |
32 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_direction_row_align_items_center_margin_oneside.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
24 |
31 |
32 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_divider_test_direction_column.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
28 |
29 |
34 |
35 |
40 |
41 |
46 |
47 |
52 |
53 |
58 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_divider_test_direction_row.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
28 |
29 |
34 |
35 |
40 |
41 |
46 |
47 |
52 |
53 |
58 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_empty_children.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_first_item_large_horizontal_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_first_item_large_vertical_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_first_view_gone_first_line_single_item.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
30 |
31 |
37 |
38 |
45 |
46 |
53 |
54 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_first_view_gone_layout_grow_set_for_rest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
30 |
31 |
37 |
38 |
45 |
46 |
53 |
54 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_first_view_gone_layout_shrink_set_for_rest.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
30 |
31 |
37 |
38 |
45 |
46 |
53 |
54 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flex_basis_percent_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
30 |
31 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flex_grow_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
29 |
30 |
35 |
36 |
42 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flex_item_match_parent.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
32 |
33 |
38 |
39 |
44 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flex_item_match_parent_direction_column.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
32 |
33 |
38 |
39 |
44 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flex_wrap_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
32 |
33 |
39 |
40 |
46 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flexbox_wrap_content.xml:
--------------------------------------------------------------------------------
1 |
17 |
24 |
25 |
30 |
31 |
36 |
37 |
42 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flexbox_wrapped_with_horizontalscrollview.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
22 |
23 |
29 |
30 |
35 |
36 |
41 |
42 |
47 |
48 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_flexbox_wrapped_with_scrollview.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
19 |
22 |
23 |
29 |
30 |
35 |
36 |
41 |
42 |
47 |
48 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_justify_content_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
29 |
30 |
35 |
36 |
41 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_justify_content_with_gone.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
29 |
30 |
36 |
37 |
42 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_justify_content_with_parent_padding.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_maxheight_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
29 |
30 |
36 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_maxheight_upper_bound_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
31 |
32 |
38 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_maxwidth_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
21 |
22 |
28 |
29 |
35 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_maxwidth_upper_bound_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
30 |
31 |
37 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_minheight_lower_bound_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
30 |
31 |
36 |
37 |
42 |
43 |
48 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_minheight_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
29 |
30 |
36 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_minwidth_lower_bound_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
29 |
30 |
35 |
36 |
41 |
42 |
47 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_minwidth_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
21 |
22 |
28 |
29 |
35 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_order_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
23 |
28 |
29 |
34 |
35 |
40 |
41 |
45 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_simple.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
33 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_stretch_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_views_visibility_gone.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
30 |
31 |
37 |
38 |
43 |
44 |
49 |
50 |
55 |
56 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_views_visibility_invisible.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
30 |
31 |
37 |
38 |
43 |
44 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_visibility_gone_first_item_in_flex_line_column.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
29 |
30 |
35 |
36 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_visibility_gone_first_item_in_flex_line_row.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
29 |
30 |
35 |
36 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_before_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
23 |
24 |
29 |
30 |
36 |
37 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_child_margin_horizontal_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
30 |
31 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_child_margin_vertical_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
30 |
31 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_content_child_bottom_margin_column_grow.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
37 |
38 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_content_child_bottom_margin_column_shrink.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
35 |
36 |
42 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_content_child_bottom_margin_row_grow.xml:
--------------------------------------------------------------------------------
1 |
16 |
24 |
25 |
34 |
35 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_content_child_bottom_margin_row_shrink.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
25 |
26 |
33 |
34 |
40 |
41 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_parent_padding_horizontal_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_wrap_parent_padding_vertical_test.xml:
--------------------------------------------------------------------------------
1 |
16 |
25 |
26 |
31 |
32 |
37 |
38 |
43 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_zero_height_positive_flexgrow.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
24 |
25 |
31 |
32 |
38 |
39 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/activity_zero_width_positive_flexgrow.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
23 |
29 |
30 |
36 |
37 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/recyclerview.xml:
--------------------------------------------------------------------------------
1 |
16 |
18 |
22 |
23 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/recyclerview_reverse.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
26 |
27 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/recyclerview_viewholder.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
21 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/viewholder_inner_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/viewholder_inner_recyclerview_wrap_horizontally.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
23 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/viewholder_textview.xml:
--------------------------------------------------------------------------------
1 |
16 |
22 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/wrapped_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
16 |
18 |
22 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/layout/wrapped_recyclerview_scroll_vertical.xml:
--------------------------------------------------------------------------------
1 |
16 |
18 |
22 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/flexbox/src/androidTest/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 | %1$s - %2$s
18 |
19 |
--------------------------------------------------------------------------------
/flexbox/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/flexbox/src/main/java/com/google/android/flexbox/AlignContent.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox;
18 |
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 |
22 | import androidx.annotation.IntDef;
23 |
24 | /** This attribute controls the alignment of the flex lines in the flex container. */
25 | @IntDef({AlignContent.FLEX_START, AlignContent.FLEX_END, AlignContent.CENTER,
26 | AlignContent.SPACE_BETWEEN, AlignContent.SPACE_AROUND, AlignContent.STRETCH})
27 | @Retention(RetentionPolicy.SOURCE)
28 | public @interface AlignContent {
29 |
30 | /** Flex lines are packed to the start of the flex container. */
31 | int FLEX_START = 0;
32 |
33 | /** Flex lines are packed to the end of the flex container. */
34 | int FLEX_END = 1;
35 |
36 | /** Flex lines are centered in the flex container. */
37 | int CENTER = 2;
38 |
39 | /**
40 | * Flex lines are evenly distributed in the flex container. The first flex line is
41 | * placed at the start of the flex container, the last flex line is placed at the
42 | * end of the flex container.
43 | */
44 | int SPACE_BETWEEN = 3;
45 |
46 | /**
47 | * Flex lines are evenly distributed in the flex container with the same amount of spaces
48 | * between the flex lines.
49 | */
50 | int SPACE_AROUND = 4;
51 |
52 | /**
53 | * Flex lines are stretched to fill the remaining space along the cross axis.
54 | */
55 | int STRETCH = 5;
56 | }
57 |
--------------------------------------------------------------------------------
/flexbox/src/main/java/com/google/android/flexbox/AlignItems.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox;
18 |
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 |
22 | import androidx.annotation.IntDef;
23 |
24 | /** This attribute controls the alignment along the cross axis. */
25 | @IntDef({AlignItems.FLEX_START, AlignItems.FLEX_END, AlignItems.CENTER,
26 | AlignItems.BASELINE, AlignItems.STRETCH})
27 | @Retention(RetentionPolicy.SOURCE)
28 | public @interface AlignItems {
29 |
30 | /** Flex item's edge is placed on the cross start line. */
31 | int FLEX_START = 0;
32 |
33 | /** Flex item's edge is placed on the cross end line. */
34 | int FLEX_END = 1;
35 |
36 | /** Flex item's edge is centered along the cross axis. */
37 | int CENTER = 2;
38 |
39 | /** Flex items are aligned based on their text's baselines. */
40 | int BASELINE = 3;
41 |
42 | /** Flex items are stretched to fill the flex line's cross size. */
43 | int STRETCH = 4;
44 | }
45 |
--------------------------------------------------------------------------------
/flexbox/src/main/java/com/google/android/flexbox/FlexDirection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox;
18 |
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 |
22 | import androidx.annotation.IntDef;
23 |
24 | /**
25 | * The direction children items are placed inside the flex container, it determines the
26 | * direction of the main axis (and the cross axis, perpendicular to the main axis).
27 | */
28 | @IntDef({FlexDirection.ROW, FlexDirection.ROW_REVERSE, FlexDirection.COLUMN,
29 | FlexDirection.COLUMN_REVERSE})
30 | @Retention(RetentionPolicy.SOURCE)
31 | public @interface FlexDirection {
32 |
33 | /**
34 | * Main axis direction -> horizontal. Main start to
35 | * main end -> Left to right (in LTR languages).
36 | * Cross start to cross end -> Top to bottom
37 | */
38 | int ROW = 0;
39 |
40 | /**
41 | * Main axis direction -> horizontal. Main start
42 | * to main end -> Right to left (in LTR languages). Cross start to cross end ->
43 | * Top to bottom.
44 | */
45 | int ROW_REVERSE = 1;
46 |
47 | /**
48 | * Main axis direction -> vertical. Main start
49 | * to main end -> Top to bottom. Cross start to cross end ->
50 | * Left to right (In LTR languages).
51 | */
52 | int COLUMN = 2;
53 |
54 | /**
55 | * Main axis direction -> vertical. Main start
56 | * to main end -> Bottom to top. Cross start to cross end -> Left to right
57 | * (In LTR languages)
58 | */
59 | int COLUMN_REVERSE = 3;
60 | }
61 |
--------------------------------------------------------------------------------
/flexbox/src/main/java/com/google/android/flexbox/FlexWrap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 com.google.android.flexbox;
18 |
19 | import java.lang.annotation.Retention;
20 | import java.lang.annotation.RetentionPolicy;
21 |
22 | import androidx.annotation.IntDef;
23 |
24 | /**
25 | * This attribute controls whether the flex container is single-line or multi-line, and the
26 | * direction of the cross axis.
27 | */
28 | @IntDef({FlexWrap.NOWRAP, FlexWrap.WRAP, FlexWrap.WRAP_REVERSE})
29 | @Retention(RetentionPolicy.SOURCE)
30 | public @interface FlexWrap {
31 |
32 | /** The flex container is single-line. */
33 | int NOWRAP = 0;
34 |
35 | /** The flex container is multi-line. */
36 | int WRAP = 1;
37 |
38 | /**
39 | * The flex container is multi-line. The direction of the
40 | * cross axis is opposed to the direction as the {@link #WRAP}
41 | */
42 | int WRAP_REVERSE = 2;
43 | }
44 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2016 Google Inc. All rights reserved.
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 | # Project-wide Gradle settings.
18 |
19 | # IDE (e.g. Android Studio) users:
20 | # Gradle settings configured through the IDE *will override*
21 | # any settings specified in this file.
22 |
23 | # For more details on how to configure your build environment visit
24 | # http://www.gradle.org/docs/current/userguide/build_environment.html
25 |
26 | # Specifies the JVM arguments used for the daemon process.
27 | # The setting is particularly useful for tweaking memory settings.
28 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
29 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
30 |
31 | # When configured, Gradle will run in incubating parallel mode.
32 | # This option should only be used with decoupled projects. More details, visit
33 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
34 | # org.gradle.parallel=true
35 |
36 | android.enableJetifier=true
37 | android.useAndroidX=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/flexbox-layout/366b461fd0425bfaa9872b1d9af9da3055d3bc74/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Sep 09 14:42:19 PDT 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
7 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Google Inc. All rights reserved.
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 | include ':demo-playground', ':demo-cat-gallery', ':flexbox'
18 |
--------------------------------------------------------------------------------