add flutter
This commit is contained in:
1
OnTime_Merchant_live/lib/flexbox-layout/flexbox/.gitignore
vendored
Executable file
1
OnTime_Merchant_live/lib/flexbox-layout/flexbox/.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
/build
|
||||
59
OnTime_Merchant_live/lib/flexbox-layout/flexbox/build.gradle
Executable file
59
OnTime_Merchant_live/lib/flexbox-layout/flexbox/build.gradle
Executable file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply from: 'maven-puglisher-plugin.gradle'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "$mavenVersion"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
}
|
||||
}
|
||||
|
||||
libraryVariants.all {
|
||||
it.generateBuildConfigProvider.configure { enabled = false }
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "androidx.core:core:${rootProject.androidxCoreVersion}"
|
||||
compileOnly "androidx.recyclerview:recyclerview:${rootProject.androidxRecyclerViewVersion}"
|
||||
|
||||
testImplementation "junit:junit:${rootProject.junitVersion}"
|
||||
|
||||
androidTestImplementation "androidx.core:core:${rootProject.androidxCoreVersion}"
|
||||
androidTestImplementation "androidx.recyclerview:recyclerview:${rootProject.androidxRecyclerViewVersion}"
|
||||
androidTestImplementation "androidx.annotation:annotation:${rootProject.androidxAnnotationVersion}"
|
||||
androidTestImplementation "androidx.test.ext:junit:${rootProject.androidxTestExtVersion}"
|
||||
androidTestImplementation "androidx.test:runner:${rootProject.androidxTestVersion}"
|
||||
androidTestImplementation "androidx.test:rules:${rootProject.androidxTestVersion}"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:${rootProject.androidxEspressoVersion}"
|
||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.kotlinVersion}"
|
||||
}
|
||||
28
OnTime_Merchant_live/lib/flexbox-layout/flexbox/constants.gradle
Executable file
28
OnTime_Merchant_live/lib/flexbox-layout/flexbox/constants.gradle
Executable file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
ext {
|
||||
projectName = 'flexbox-layout'
|
||||
projectDesc = 'Flexbox for Android'
|
||||
|
||||
githubUrl = 'https://github.com/google/flexbox-layout'
|
||||
|
||||
mavenGroup = 'com.google.android.flexbox'
|
||||
mavenArtifactId = 'flexbox'
|
||||
mavenVersion = '3.0.0'
|
||||
|
||||
bintrayOrg = 'google'
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2021 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
apply plugin: 'maven-publish'
|
||||
apply from: 'constants.gradle'
|
||||
|
||||
afterEvaluate {
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
from components.release
|
||||
|
||||
groupId = "$mavenGroup"
|
||||
artifactId = "$mavenArtifactId"
|
||||
version = "$mavenVersion"
|
||||
|
||||
artifact androidSourcesJar
|
||||
|
||||
pom {
|
||||
name = "$projectName"
|
||||
description = "$projectDesc"
|
||||
licenses {
|
||||
license {
|
||||
name = 'The Apache Software License, Version 2.0'
|
||||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
distribution = 'repo'
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
name = 'Google'
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = "${githubUrl}.git"
|
||||
url = githubUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task androidSourcesJar(type: Jar) {
|
||||
archiveClassifier.set('sources')
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
20
OnTime_Merchant_live/lib/flexbox-layout/flexbox/proguard-rules.txt
Executable file
20
OnTime_Merchant_live/lib/flexbox-layout/flexbox/proguard-rules.txt
Executable file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright 2016 Google Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# The FlexboxLayoutManager may be set from a layout xml, in that situation the RecyclerView
|
||||
# tries to instantiate the layout manager using reflection.
|
||||
# This is to prevent the layout manager from being obfuscated.
|
||||
-keepnames public class com.google.android.flexbox.FlexboxLayoutManager
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest
|
||||
package="com.google.android.flexbox.test"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity android:name=".FlexboxTestActivity"/>
|
||||
<activity android:name=".ConfigChangeActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
||||
/**
|
||||
* Fake implementation of [FlexContainer].
|
||||
*/
|
||||
internal class FakeFlexContainer : FlexContainer {
|
||||
|
||||
private val views = mutableListOf<View>()
|
||||
|
||||
private var flexLines = mutableListOf<FlexLine>()
|
||||
|
||||
@FlexDirection
|
||||
private var flexDirection = FlexDirection.ROW
|
||||
|
||||
@FlexWrap
|
||||
private var flexWrap = FlexWrap.WRAP
|
||||
|
||||
@JustifyContent
|
||||
private var justifyContent = JustifyContent.FLEX_START
|
||||
|
||||
@AlignItems
|
||||
private var alignItems = AlignItems.STRETCH
|
||||
|
||||
@AlignContent
|
||||
private var alignContent = AlignContent.STRETCH
|
||||
|
||||
private var maxLine = -1
|
||||
|
||||
override fun getFlexItemCount() = views.size
|
||||
|
||||
override fun getFlexItemAt(index: Int) = views[index]
|
||||
|
||||
override fun getReorderedFlexItemAt(index: Int) = views[index]
|
||||
|
||||
override fun addView(view: View) {
|
||||
views.add(view)
|
||||
}
|
||||
|
||||
override fun addView(view: View, index: Int) {
|
||||
views.add(index, view)
|
||||
}
|
||||
|
||||
override fun removeAllViews() {
|
||||
views.clear()
|
||||
}
|
||||
|
||||
override fun removeViewAt(index: Int) {
|
||||
views.removeAt(index)
|
||||
}
|
||||
|
||||
override fun getFlexDirection() = flexDirection
|
||||
|
||||
override fun setFlexDirection(@FlexDirection flexDirection: Int) {
|
||||
this.flexDirection = flexDirection
|
||||
}
|
||||
|
||||
override fun getFlexWrap() = flexWrap
|
||||
|
||||
override fun setFlexWrap(@FlexWrap flexWrap: Int) {
|
||||
this.flexWrap = flexWrap
|
||||
}
|
||||
|
||||
override fun getJustifyContent() = justifyContent
|
||||
|
||||
override fun setJustifyContent(@JustifyContent justifyContent: Int) {
|
||||
this.justifyContent = justifyContent
|
||||
}
|
||||
|
||||
override fun getAlignContent() = alignContent
|
||||
|
||||
override fun setAlignContent(@AlignContent alignContent: Int) {
|
||||
this.alignContent = alignContent
|
||||
}
|
||||
|
||||
override fun getAlignItems() = alignItems
|
||||
|
||||
override fun setAlignItems(@AlignItems alignItems: Int) {
|
||||
this.alignItems = alignItems
|
||||
}
|
||||
|
||||
override fun getMaxLine(): Int = this.maxLine
|
||||
|
||||
override fun setMaxLine(maxLine: Int) {
|
||||
this.maxLine = maxLine
|
||||
}
|
||||
|
||||
override fun getFlexLines() = flexLines
|
||||
|
||||
override fun isMainAxisDirectionHorizontal(): Boolean {
|
||||
return flexDirection == FlexDirection.ROW || flexDirection == FlexDirection.ROW_REVERSE
|
||||
}
|
||||
|
||||
override fun getDecorationLengthMainAxis(view: View, index: Int, indexInFlexLine: Int) = 0
|
||||
|
||||
override fun getDecorationLengthCrossAxis(view: View) = 0
|
||||
|
||||
override fun getPaddingTop() = 0
|
||||
|
||||
override fun getPaddingLeft() = 0
|
||||
|
||||
override fun getPaddingRight() = 0
|
||||
|
||||
override fun getPaddingBottom() = 0
|
||||
|
||||
override fun getPaddingStart() = 0
|
||||
|
||||
override fun getPaddingEnd() = 0
|
||||
|
||||
override fun getChildWidthMeasureSpec(widthSpec: Int, padding: Int, childDimension: Int): Int {
|
||||
return ViewGroup.getChildMeasureSpec(widthSpec, padding, childDimension)
|
||||
}
|
||||
|
||||
override fun getChildHeightMeasureSpec(heightSpec: Int, padding: Int, childDimension: Int): Int {
|
||||
return ViewGroup.getChildMeasureSpec(heightSpec, padding, childDimension)
|
||||
}
|
||||
|
||||
override fun getLargestMainSize() = flexLines.maxBy { it.mMainSize }?.mMainSize ?: Integer.MIN_VALUE
|
||||
|
||||
override fun getSumOfCrossSize() = flexLines.sumBy { it.mCrossSize }
|
||||
|
||||
override fun onNewFlexItemAdded(view: View, index: Int, indexInFlexLine: Int, flexLine: FlexLine) = Unit
|
||||
|
||||
override fun onNewFlexLineAdded(flexLine: FlexLine) = Unit
|
||||
|
||||
override fun setFlexLines(flexLines: List<FlexLine>) {
|
||||
this.flexLines = flexLines.toMutableList()
|
||||
}
|
||||
|
||||
override fun getFlexLinesInternal() = flexLines
|
||||
|
||||
override fun updateViewCache(position: Int, view: View) = Unit
|
||||
}
|
||||
@@ -0,0 +1,613 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox
|
||||
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.TextView
|
||||
import androidx.core.widget.CompoundButtonCompat
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import com.google.android.flexbox.test.FlexboxTestActivity
|
||||
import com.google.android.flexbox.test.IsEqualAllowingError.Companion.isEqualAllowingError
|
||||
import org.hamcrest.Matchers.`is`
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Unit tests for [FlexboxHelper].
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class FlexboxHelperTest {
|
||||
|
||||
private val LONG_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do " +
|
||||
"eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " +
|
||||
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo " +
|
||||
"consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum " +
|
||||
"dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, " +
|
||||
"sunt in culpa qui officia deserunt mollit anim id est laborum."
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
var activityRule = ActivityTestRule(FlexboxTestActivity::class.java)
|
||||
|
||||
private lateinit var flexboxHelper: FlexboxHelper
|
||||
|
||||
private lateinit var flexContainer: FlexContainer
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
flexContainer = FakeFlexContainer()
|
||||
flexboxHelper = FlexboxHelper(flexContainer)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testCalculateHorizontalFlexLines() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(200, 100)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(300, 100)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(400, 100)
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexWrap = FlexWrap.WRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
|
||||
flexboxHelper.ensureIndexToFlexLine(flexContainer.flexItemCount)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
assertEquals(3, result.mFlexLines.size)
|
||||
assertEquals(300, result.mFlexLines[0].mainSize)
|
||||
assertEquals(300, result.mFlexLines[1].mainSize)
|
||||
assertEquals(400, result.mFlexLines[2].mainSize)
|
||||
assertEquals(100, result.mFlexLines[0].crossSize)
|
||||
assertEquals(100, result.mFlexLines[1].crossSize)
|
||||
assertEquals(100, result.mFlexLines[2].crossSize)
|
||||
|
||||
assertNotNull(flexboxHelper.mIndexToFlexLine)
|
||||
assertEquals(0, flexboxHelper.mIndexToFlexLine!![0])
|
||||
assertEquals(0, flexboxHelper.mIndexToFlexLine!![1])
|
||||
assertEquals(1, flexboxHelper.mIndexToFlexLine!![2])
|
||||
assertEquals(2, flexboxHelper.mIndexToFlexLine!![3])
|
||||
|
||||
val firstLine = result.mFlexLines[0]
|
||||
assertEquals(0, firstLine.mFirstIndex)
|
||||
assertEquals(1, firstLine.mLastIndex)
|
||||
val secondLine = result.mFlexLines[1]
|
||||
assertEquals(2, secondLine.mFirstIndex)
|
||||
assertEquals(2, secondLine.mLastIndex)
|
||||
val thirdLine = result.mFlexLines[2]
|
||||
assertEquals(3, thirdLine.mFirstIndex)
|
||||
assertEquals(3, thirdLine.mLastIndex)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testCalculateVerticalFlexLines() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(100, 300)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(100, 400)
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexWrap = FlexWrap.WRAP
|
||||
flexContainer.flexDirection = FlexDirection.COLUMN
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
|
||||
flexboxHelper.ensureIndexToFlexLine(flexContainer.flexItemCount)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateVerticalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
assertEquals(3, result.mFlexLines.size)
|
||||
assertEquals(300, result.mFlexLines[0].mainSize)
|
||||
assertEquals(300, result.mFlexLines[1].mainSize)
|
||||
assertEquals(400, result.mFlexLines[2].mainSize)
|
||||
assertEquals(100, result.mFlexLines[0].crossSize)
|
||||
assertEquals(100, result.mFlexLines[1].crossSize)
|
||||
assertEquals(100, result.mFlexLines[2].crossSize)
|
||||
|
||||
assertNotNull(flexboxHelper.mIndexToFlexLine)
|
||||
assertEquals(0, flexboxHelper.mIndexToFlexLine!![0])
|
||||
assertEquals(0, flexboxHelper.mIndexToFlexLine!![1])
|
||||
assertEquals(1, flexboxHelper.mIndexToFlexLine!![2])
|
||||
assertEquals(2, flexboxHelper.mIndexToFlexLine!![3])
|
||||
|
||||
val firstLine = result.mFlexLines[0]
|
||||
assertEquals(0, firstLine.mFirstIndex)
|
||||
assertEquals(1, firstLine.mLastIndex)
|
||||
val secondLine = result.mFlexLines[1]
|
||||
assertEquals(2, secondLine.mFirstIndex)
|
||||
assertEquals(2, secondLine.mLastIndex)
|
||||
val thirdLine = result.mFlexLines[2]
|
||||
assertEquals(3, thirdLine.mFirstIndex)
|
||||
assertEquals(3, thirdLine.mLastIndex)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_direction_row_flexGrowSet() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(200, 100)
|
||||
lp2.flexGrow = 1.0f
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(300, 100)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(400, 100)
|
||||
lp4.flexGrow = 2.0f
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexDirection = FlexDirection.ROW
|
||||
flexContainer.flexWrap = FlexWrap.WRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
assertThat(view1.measuredWidth, `is`(100))
|
||||
assertThat(view1.measuredHeight, `is`(100))
|
||||
// view2 will expand to fill the left space in the first flex line since flex grow is set
|
||||
assertThat(view2.measuredWidth, `is`(400))
|
||||
assertThat(view2.measuredHeight, `is`(100))
|
||||
assertThat(view3.measuredWidth, `is`(300))
|
||||
assertThat(view3.measuredHeight, `is`(100))
|
||||
// view4 will expand to fill the left space in the first flex line since flex grow is set
|
||||
assertThat(view4.measuredWidth, `is`(500))
|
||||
assertThat(view4.measuredHeight, `is`(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_direction_column_flexGrowSet() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(100, 200)
|
||||
lp2.flexGrow = 1.0f
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(100, 300)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(100, 400)
|
||||
lp4.flexGrow = 2.0f
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexDirection = FlexDirection.COLUMN
|
||||
flexContainer.flexWrap = FlexWrap.WRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateVerticalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
assertThat(view1.measuredWidth, `is`(100))
|
||||
assertThat(view1.measuredHeight, `is`(100))
|
||||
assertThat(view2.measuredWidth, `is`(100))
|
||||
// view2 will expand to fill the left space in the first flex line since flex grow is set
|
||||
assertThat(view2.measuredHeight, `is`(400))
|
||||
assertThat(view3.measuredWidth, `is`(100))
|
||||
assertThat(view3.measuredHeight, `is`(300))
|
||||
assertThat(view4.measuredWidth, `is`(100))
|
||||
// view4 will expand to fill the left space in the first flex line since flex grow is set
|
||||
assertThat(view4.measuredHeight, `is`(500))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_direction_row_flexShrinkSet() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(200, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(200, 100)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(200, 100)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(200, 100)
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexDirection = FlexDirection.ROW
|
||||
flexContainer.flexWrap = FlexWrap.NOWRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateVerticalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
// Flex shrink is set to 1.0 (default value) for all views.
|
||||
// They should be shrank equally for the amount overflown the width
|
||||
assertThat(view1.measuredWidth, `is`(125))
|
||||
assertThat(view1.measuredHeight, `is`(100))
|
||||
assertThat(view2.measuredWidth, `is`(125))
|
||||
assertThat(view2.measuredHeight, `is`(100))
|
||||
assertThat(view3.measuredWidth, `is`(125))
|
||||
assertThat(view3.measuredHeight, `is`(100))
|
||||
assertThat(view4.measuredWidth, `is`(125))
|
||||
assertThat(view4.measuredHeight, `is`(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_direction_column_flexShrinkSet() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexDirection = FlexDirection.COLUMN
|
||||
flexContainer.flexWrap = FlexWrap.NOWRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateVerticalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
// Flex shrink is set to 1.0 (default value) for all views.
|
||||
// They should be shrank equally for the amount overflown the height
|
||||
assertThat(view1.measuredWidth, `is`(100))
|
||||
assertThat(view1.measuredHeight, `is`(125))
|
||||
assertThat(view2.measuredWidth, `is`(100))
|
||||
assertThat(view2.measuredHeight, `is`(125))
|
||||
assertThat(view3.measuredWidth, `is`(100))
|
||||
assertThat(view3.measuredHeight, `is`(125))
|
||||
assertThat(view4.measuredWidth, `is`(100))
|
||||
assertThat(view4.measuredHeight, `is`(125))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_directionRow_fixedSizeViewAndShrinkable_doNotExceedMaxMainSize() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
lp1.flexShrink = 0f
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT)
|
||||
val view2 = TextView(activity)
|
||||
view2.layoutParams = lp2
|
||||
view2.text = LONG_TEXT
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.flexWrap = FlexWrap.NOWRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.AT_MOST)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
// Container with WRAP_CONTENT and a max width forces resizable children to shrink
|
||||
// to avoid exceeding max available space.
|
||||
assertThat(view1.measuredWidth, `is`(100))
|
||||
assertThat(view2.measuredWidth, `is`(400))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_directionRow_twoFixedSizeViewsAndShrinkable_doNotExceedMaxMainSize() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
lp1.flexShrink = 0f
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT)
|
||||
val view2 = TextView(activity)
|
||||
view2.layoutParams = lp2
|
||||
view2.text = LONG_TEXT
|
||||
val lp3 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view3 = View(activity)
|
||||
lp3.flexShrink = 0f
|
||||
view3.layoutParams = lp3
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.flexWrap = FlexWrap.NOWRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.AT_MOST)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
// Container with WRAP_CONTENT and a max width forces resizable children to shrink
|
||||
// to avoid exceeding max available space.
|
||||
assertThat(view1.measuredWidth, `is`(100))
|
||||
assertThat(view2.measuredWidth, `is`(300))
|
||||
assertThat(view3.measuredWidth, `is`(100))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_directionRow_considerCompoundButtonImplicitMinSizeWhenNotSpecified() {
|
||||
val containerWidth = 500
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT)
|
||||
val view1 = CheckBox(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT)
|
||||
val view2 = TextView(activity)
|
||||
view2.layoutParams = lp2
|
||||
view2.text = LONG_TEXT
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.flexWrap = FlexWrap.NOWRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(containerWidth, View.MeasureSpec.AT_MOST)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
// CompoundButton will use its ButtonDrawable minWidth to determine its size when
|
||||
// no minimum width is set on it.
|
||||
val drawableMinWidth = CompoundButtonCompat.getButtonDrawable(view1)!!.minimumWidth
|
||||
val expectedTextWidth = containerWidth - drawableMinWidth
|
||||
assertThat(view1.measuredWidth, `is`(drawableMinWidth))
|
||||
assertThat(view2.measuredWidth, `is`(expectedTextWidth))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineMainSize_directionRow_considerCompoundButtonExplicitMinSizeWhenSpecified() {
|
||||
val containerWidth = 500
|
||||
val compoundButtonMinWidth = 150
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT)
|
||||
lp1.minWidth = compoundButtonMinWidth
|
||||
val view1 = CheckBox(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT,
|
||||
FlexboxLayout.LayoutParams.WRAP_CONTENT)
|
||||
val view2 = TextView(activity)
|
||||
view2.layoutParams = lp2
|
||||
view2.text = LONG_TEXT
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.flexWrap = FlexWrap.NOWRAP
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(containerWidth, View.MeasureSpec.AT_MOST)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.UNSPECIFIED)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
|
||||
// CompoundButton will be measured based on its explicitly specified minWidth.
|
||||
val expectedTextWidth = containerWidth - compoundButtonMinWidth
|
||||
assertThat(view1.measuredWidth, `is`(compoundButtonMinWidth))
|
||||
assertThat(view2.measuredWidth, `is`(expectedTextWidth))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineCrossSize_direction_row_alignContent_stretch() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(200, 100)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(300, 100)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(400, 100)
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexDirection = FlexDirection.ROW
|
||||
flexContainer.flexWrap = FlexWrap.WRAP
|
||||
flexContainer.alignContent = AlignContent.STRETCH
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateHorizontalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
flexboxHelper.determineCrossSize(widthMeasureSpec, heightMeasureSpec, 0)
|
||||
flexboxHelper.stretchViews()
|
||||
|
||||
// align content is set to Align.STRETCH, the cross size for each flex line is stretched
|
||||
// to distribute the remaining free space along the cross axis
|
||||
// (remaining height in this case)
|
||||
assertThat(view1.measuredHeight, isEqualAllowingError(333))
|
||||
assertThat(view2.measuredHeight, isEqualAllowingError(333))
|
||||
assertThat(view3.measuredHeight, isEqualAllowingError(333))
|
||||
assertThat(view4.measuredHeight, isEqualAllowingError(333))
|
||||
}
|
||||
|
||||
@Test
|
||||
@Throws(Throwable::class)
|
||||
fun testDetermineCrossSize_direction_column_alignContent_stretch() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100)
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(100, 300)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(100, 400)
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.addView(view1)
|
||||
flexContainer.addView(view2)
|
||||
flexContainer.addView(view3)
|
||||
flexContainer.addView(view4)
|
||||
flexContainer.flexDirection = FlexDirection.COLUMN
|
||||
flexContainer.flexWrap = FlexWrap.WRAP
|
||||
flexContainer.alignContent = AlignContent.STRETCH
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateVerticalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
flexboxHelper.determineMainSize(widthMeasureSpec, heightMeasureSpec)
|
||||
flexboxHelper.determineCrossSize(widthMeasureSpec, heightMeasureSpec, 0)
|
||||
flexboxHelper.stretchViews()
|
||||
|
||||
// align content is set to Align.STRETCH, the cross size for each flex line is stretched
|
||||
// to distribute the remaining free space along the cross axis
|
||||
// (remaining width in this case)
|
||||
assertThat(view1.measuredWidth, isEqualAllowingError(333))
|
||||
assertThat(view2.measuredWidth, isEqualAllowingError(333))
|
||||
assertThat(view3.measuredWidth, isEqualAllowingError(333))
|
||||
assertThat(view4.measuredWidth, isEqualAllowingError(333))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMakeCombinedLong() {
|
||||
var higher = -1
|
||||
var lower = 10
|
||||
var combined = flexboxHelper.makeCombinedLong(lower, higher)
|
||||
assertThat(flexboxHelper.extractHigherInt(combined), `is`(higher))
|
||||
assertThat(flexboxHelper.extractLowerInt(combined), `is`(lower))
|
||||
|
||||
higher = Integer.MAX_VALUE
|
||||
lower = Integer.MIN_VALUE
|
||||
combined = flexboxHelper.makeCombinedLong(lower, higher)
|
||||
assertThat(flexboxHelper.extractHigherInt(combined), `is`(higher))
|
||||
assertThat(flexboxHelper.extractLowerInt(combined), `is`(lower))
|
||||
|
||||
higher = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
lower = View.MeasureSpec.makeMeasureSpec(300, View.MeasureSpec.UNSPECIFIED)
|
||||
combined = flexboxHelper.makeCombinedLong(lower, higher)
|
||||
assertThat(flexboxHelper.extractHigherInt(combined), `is`(higher))
|
||||
assertThat(flexboxHelper.extractLowerInt(combined), `is`(lower))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFlexLine_anyItemsHaveFlexGrow() {
|
||||
val activity = activityRule.activity
|
||||
val lp1 = FlexboxLayout.LayoutParams(100, 100).apply {
|
||||
flexGrow = 1.0f
|
||||
}
|
||||
val view1 = View(activity)
|
||||
view1.layoutParams = lp1
|
||||
val lp2 = FlexboxLayout.LayoutParams(100, 200)
|
||||
val view2 = View(activity)
|
||||
view2.layoutParams = lp2
|
||||
val lp3 = FlexboxLayout.LayoutParams(100, 300)
|
||||
val view3 = View(activity)
|
||||
view3.layoutParams = lp3
|
||||
val lp4 = FlexboxLayout.LayoutParams(100, 400).apply {
|
||||
flexGrow = 2.0f
|
||||
}
|
||||
val view4 = View(activity)
|
||||
view4.layoutParams = lp4
|
||||
flexContainer.apply {
|
||||
addView(view1)
|
||||
addView(view2)
|
||||
addView(view3)
|
||||
addView(view4)
|
||||
flexDirection = FlexDirection.COLUMN
|
||||
flexWrap = FlexWrap.WRAP
|
||||
alignContent = AlignContent.STRETCH
|
||||
}
|
||||
val widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(1000, View.MeasureSpec.EXACTLY)
|
||||
val heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(500, View.MeasureSpec.EXACTLY)
|
||||
val result = FlexboxHelper.FlexLinesResult()
|
||||
flexboxHelper.calculateVerticalFlexLines(result, widthMeasureSpec, heightMeasureSpec)
|
||||
flexContainer.flexLines = result.mFlexLines
|
||||
assertThat(flexContainer.flexLines.size, `is`(3))
|
||||
assertThat(flexContainer.flexLines[0].mAnyItemsHaveFlexGrow, `is`(true))
|
||||
assertThat(flexContainer.flexLines[1].mAnyItemsHaveFlexGrow, `is`(false))
|
||||
assertThat(flexContainer.flexLines[2].mAnyItemsHaveFlexGrow, `is`(true))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.res.Configuration
|
||||
import android.util.Log
|
||||
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
|
||||
/**
|
||||
* Activity for testing the [FlexboxLayout] that handles configuration changes by itself
|
||||
* instead of letting the system take care of those.
|
||||
*/
|
||||
class ConfigChangeActivity : Activity() {
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
|
||||
Log.d(TAG, "onConfigurationChanged: $newConfig")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ConfigChangeActivity"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.InstrumentationRegistry
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.ViewAction
|
||||
import androidx.test.espresso.action.*
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.filters.FlakyTest
|
||||
import androidx.test.filters.MediumTest
|
||||
import androidx.test.rule.ActivityTestRule
|
||||
import androidx.test.runner.AndroidJUnit4
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
import org.hamcrest.Matchers.`is`
|
||||
import org.hamcrest.core.IsNot.not
|
||||
import org.junit.Assert.assertThat
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Integration tests for [FlexboxLayoutManager] with the Activity that handles configuration
|
||||
* changes manually.
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@MediumTest
|
||||
class FlexboxLayoutManagerConfigChangeTest {
|
||||
|
||||
@JvmField
|
||||
@Rule
|
||||
var activityRule = ActivityTestRule(ConfigChangeActivity::class.java)
|
||||
|
||||
@Test
|
||||
@FlakyTest
|
||||
@Throws(Throwable::class)
|
||||
fun testFlexLinesDiscardedOnOrientationChange_direction_row() {
|
||||
// Verifies the case that the calculated Flex lines are correctly discarded when a
|
||||
// orientation happens with an Activity that handles configuration changes manually
|
||||
val activity = activityRule.activity
|
||||
val layoutManager = FlexboxLayoutManager(activity)
|
||||
val adapter = TestAdapter()
|
||||
|
||||
activityRule.runOnUiThread {
|
||||
activity.setContentView(R.layout.recyclerview)
|
||||
val recyclerView = activity.findViewById<RecyclerView>(R.id.recyclerview)
|
||||
// This test assumes that the screen width and the height are different.
|
||||
recyclerView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
recyclerView.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
layoutManager.flexDirection = FlexDirection.ROW
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
for (i in 0..99) {
|
||||
val lp = createLayoutParams(activity, 90, 65)
|
||||
adapter.addItem(lp)
|
||||
}
|
||||
}
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
|
||||
val firstLine = layoutManager.flexLines[0]
|
||||
assertThat(layoutManager.flexDirection, `is`(FlexDirection.ROW))
|
||||
onView(withId(R.id.recyclerview)).perform(swipe(GeneralLocation.BOTTOM_CENTER,
|
||||
GeneralLocation.TOP_CENTER))
|
||||
onView(withId(R.id.recyclerview)).perform(swipe(GeneralLocation.BOTTOM_CENTER,
|
||||
GeneralLocation.TOP_CENTER))
|
||||
|
||||
activityRule.runOnUiThread {
|
||||
val orientation = activity.resources.configuration.orientation
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
} else {
|
||||
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
}
|
||||
}
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
activityRule.runOnUiThread { layoutManager.scrollToPosition(0) }
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
val firstLineAfterRotation = layoutManager.flexLines[0]
|
||||
assertThat(firstLine.mainSize, `is`(not(firstLineAfterRotation.mainSize)))
|
||||
}
|
||||
|
||||
@Test
|
||||
@FlakyTest
|
||||
@Throws(Throwable::class)
|
||||
fun testFlexLinesDiscardedOnOrientationChange_direction_column() {
|
||||
// Verifies the case that the calculated Flex lines are correctly discarded when a
|
||||
// orientation happens with an Activity that handles configuration changes manually
|
||||
val activity = activityRule.activity
|
||||
val layoutManager = FlexboxLayoutManager(activity)
|
||||
val adapter = TestAdapter()
|
||||
|
||||
activityRule.runOnUiThread {
|
||||
activity.setContentView(R.layout.recyclerview)
|
||||
val recyclerView = activity.findViewById<RecyclerView>(R.id.recyclerview)
|
||||
// This test assumes that the screen width and the height are different.
|
||||
recyclerView.layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
recyclerView.layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
layoutManager.flexDirection = FlexDirection.COLUMN
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
for (i in 0..99) {
|
||||
val lp = createLayoutParams(activity, 90, 65)
|
||||
adapter.addItem(lp)
|
||||
}
|
||||
}
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
|
||||
val firstLine = layoutManager.flexLines[0]
|
||||
assertThat(layoutManager.flexDirection, `is`(FlexDirection.COLUMN))
|
||||
onView(withId(R.id.recyclerview)).perform(swipe(GeneralLocation.CENTER_RIGHT,
|
||||
GeneralLocation.CENTER_LEFT))
|
||||
onView(withId(R.id.recyclerview)).perform(swipe(GeneralLocation.CENTER_RIGHT,
|
||||
GeneralLocation.CENTER_LEFT))
|
||||
|
||||
activityRule.runOnUiThread {
|
||||
val orientation = activity.resources.configuration.orientation
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||
} else {
|
||||
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
}
|
||||
}
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
activityRule.runOnUiThread { layoutManager.scrollToPosition(0) }
|
||||
InstrumentationRegistry.getInstrumentation().waitForIdleSync()
|
||||
val firstLineAfterRotation = layoutManager.flexLines[0]
|
||||
assertThat(firstLine.mainSize, `is`(not(firstLineAfterRotation.mainSize)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new flex item.
|
||||
*
|
||||
* @param context the context
|
||||
* @param width in DP
|
||||
* @param height in DP
|
||||
* @return the created [FlexboxLayoutManager.LayoutParams] instance
|
||||
*/
|
||||
private fun createLayoutParams(context: Context, width: Int,
|
||||
height: Int): FlexboxLayoutManager.LayoutParams {
|
||||
return FlexboxLayoutManager.LayoutParams(context.dpToPixel(width), context.dpToPixel(height))
|
||||
}
|
||||
|
||||
private fun swipe(from: CoordinatesProvider, to: CoordinatesProvider): ViewAction {
|
||||
return GeneralSwipeAction(Swipe.FAST, from, to, Press.FINGER)
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.app.Activity
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
|
||||
/**
|
||||
* Activity for testing the [FlexboxLayout].
|
||||
*/
|
||||
class FlexboxTestActivity : Activity()
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import org.hamcrest.BaseMatcher
|
||||
import org.hamcrest.Description
|
||||
import org.hamcrest.Factory
|
||||
import org.hamcrest.Matcher
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Custom [BaseMatcher] that expects [Number] value allowing some errors to allow
|
||||
* such as rounding errors.
|
||||
*/
|
||||
class IsEqualAllowingError<T : Number> private constructor(private val expected: Number, private val errorAllowed: Int) : BaseMatcher<T>() {
|
||||
|
||||
override fun matches(item: Any): Boolean {
|
||||
if (item !is Number) {
|
||||
return false
|
||||
}
|
||||
return expected.toInt() - errorAllowed <= item.toInt() && item.toInt() <= expected.toInt() + errorAllowed
|
||||
}
|
||||
|
||||
override fun describeTo(description: Description) {
|
||||
description.appendText(
|
||||
String.format(Locale.US, "expected value is <%s> allowing error of <%s>.", expected,
|
||||
errorAllowed))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@Factory
|
||||
fun <T : Number> isEqualAllowingError(expected: T): Matcher<T> {
|
||||
return IsEqualAllowingError(expected, 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
/**
|
||||
* Adapter for the tests for nested RecyclerViews.
|
||||
* This Adapter is used for the inner RecyclerView.
|
||||
*/
|
||||
internal class NestedInnerAdapter(private val innerPosition: Int, private val itemCount: Int)
|
||||
: RecyclerView.Adapter<NestedInnerAdapter.InnerViewHolder>() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NestedInnerAdapter.InnerViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.viewholder_textview, parent, false)
|
||||
return InnerViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: InnerViewHolder, position: Int) {
|
||||
holder.textView.text = holder.textView.resources.getString(R.string.item_description, innerPosition, position)
|
||||
}
|
||||
|
||||
override fun getItemCount() = itemCount
|
||||
|
||||
internal class InnerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
val textView: TextView = itemView.findViewById(R.id.textview)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.flexbox.FlexDirection
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
|
||||
/**
|
||||
* Adapter for the tests for nested RecyclerViews.
|
||||
* This Adapter is used for the outer RecyclerView.
|
||||
*/
|
||||
internal class NestedOuterAdapter(
|
||||
@param:FlexDirection private val flexDirection: Int, private val innerAdapterItemCount: Int,
|
||||
@param:LayoutRes private val viewHolderResId: Int
|
||||
) : RecyclerView.Adapter<NestedOuterAdapter.OuterViewHolder>() {
|
||||
|
||||
private val viewHolderList = mutableListOf<OuterViewHolder>()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OuterViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(viewHolderResId, parent, false)
|
||||
val holder = OuterViewHolder(view)
|
||||
viewHolderList.add(holder)
|
||||
return holder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: OuterViewHolder, position: Int) {
|
||||
val layoutManager = FlexboxLayoutManager(holder.itemView.context)
|
||||
layoutManager.flexDirection = flexDirection
|
||||
holder.innerRecyclerView.layoutManager = layoutManager
|
||||
holder.innerRecyclerView.adapter = NestedInnerAdapter(position, innerAdapterItemCount)
|
||||
}
|
||||
|
||||
fun getViewHolder(position: Int) = viewHolderList[position]
|
||||
|
||||
override fun getItemCount() = ITEM_COUNT
|
||||
|
||||
internal class OuterViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val innerRecyclerView: RecyclerView = itemView.findViewById(R.id.recyclerview_inner)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ITEM_COUNT = 4
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
|
||||
/**
|
||||
* [RecyclerView.Adapter] implementation for [TestViewHolder].
|
||||
*/
|
||||
internal class TestAdapter private constructor(
|
||||
private val layoutParams: MutableList<FlexboxLayoutManager.LayoutParams>)
|
||||
: RecyclerView.Adapter<TestViewHolder>() {
|
||||
|
||||
private val receivedPayloads = mutableListOf<Any>()
|
||||
|
||||
constructor() : this(mutableListOf<FlexboxLayoutManager.LayoutParams>())
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TestViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.recyclerview_viewholder, parent, false)
|
||||
return TestViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TestViewHolder, position: Int) {
|
||||
holder.textView.text = (position + 1).toString()
|
||||
holder.textView.setBackgroundResource(R.drawable.flex_item_background)
|
||||
holder.textView.gravity = Gravity.CENTER
|
||||
holder.textView.layoutParams = layoutParams[position]
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TestViewHolder, position: Int, payloads: List<Any>) {
|
||||
receivedPayloads.addAll(payloads)
|
||||
onBindViewHolder(holder, position)
|
||||
}
|
||||
|
||||
fun addItem(position: Int, flexItem: FlexboxLayoutManager.LayoutParams) {
|
||||
layoutParams.add(position, flexItem)
|
||||
notifyItemInserted(position)
|
||||
}
|
||||
|
||||
fun addItem(flexItem: FlexboxLayoutManager.LayoutParams) {
|
||||
layoutParams.add(flexItem)
|
||||
notifyItemInserted(layoutParams.size - 1)
|
||||
}
|
||||
|
||||
fun changeItemWithPayload(position: Int, payload: Any) {
|
||||
notifyItemChanged(position, payload)
|
||||
}
|
||||
|
||||
val payloads get() = receivedPayloads.toList()
|
||||
|
||||
fun getItemAt(index: Int) = layoutParams[index]
|
||||
|
||||
override fun getItemCount() = layoutParams.size
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.flexbox.FlexboxLayoutManager
|
||||
|
||||
/**
|
||||
* [RecyclerView.Adapter] implementation for [TestViewHolder], which has multiple
|
||||
* view types.
|
||||
*/
|
||||
internal class TestAdapterMultiViewTypes : RecyclerView.Adapter<TestViewHolder>() {
|
||||
|
||||
private val items = mutableListOf<Item>()
|
||||
|
||||
init {
|
||||
for (i in 0 until ITEMS) {
|
||||
val item = Item()
|
||||
if (i == POSITION_MATCH_PARENT) {
|
||||
item.viewType = VIEW_TYPE_MATCH_PARENT
|
||||
}
|
||||
item.value = i + 1
|
||||
items.add(item)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TestViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.recyclerview_viewholder, parent, false)
|
||||
if (viewType == VIEW_TYPE_MATCH_PARENT) {
|
||||
val flexboxLp = view.layoutParams as FlexboxLayoutManager.LayoutParams
|
||||
flexboxLp.flexBasisPercent = 90f
|
||||
flexboxLp.flexGrow = 1f
|
||||
}
|
||||
return TestViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TestViewHolder, position: Int) {
|
||||
holder.textView.text = items[position].value.toString()
|
||||
holder.textView.setBackgroundResource(R.drawable.flex_item_background)
|
||||
holder.textView.gravity = Gravity.CENTER
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int) = items[position].viewType
|
||||
|
||||
fun addItemAt(position: Int, item: Item) {
|
||||
items.add(position, item)
|
||||
notifyItemInserted(position)
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
internal class Item {
|
||||
internal var viewType = VIEW_TYPE_NORMAL
|
||||
internal var value = 0
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
internal const val POSITION_MATCH_PARENT = 3
|
||||
private const val ITEMS = 50
|
||||
|
||||
private const val VIEW_TYPE_NORMAL = 0
|
||||
private const val VIEW_TYPE_MATCH_PARENT = 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.content.Context
|
||||
|
||||
internal fun Context.dpToPixel(dp: Int): Int {
|
||||
val displayMetrics = this.resources.displayMetrics
|
||||
return if (dp < 0) dp else Math.round(dp * displayMetrics.density)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox.test
|
||||
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
/**
|
||||
* ViewHolder implementation for a flex item for testing.
|
||||
*/
|
||||
internal class TestViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val textView: TextView = itemView.findViewById(R.id.textview)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<size
|
||||
android:width="10dp"
|
||||
android:height="15dp" />
|
||||
<solid android:color="#44A444" />
|
||||
</shape>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<size
|
||||
android:width="40dp"
|
||||
android:height="42dp" />
|
||||
<solid android:color="#44A444" />
|
||||
</shape>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
|
||||
<solid android:color="#11aabb" />
|
||||
<stroke android:width="1dp" android:color="#888888"/>
|
||||
</shape>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap_reverse"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text4"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text5"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="5" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text6"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="6" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="baseline">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1"
|
||||
android:gravity="bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="2"
|
||||
android:gravity="top" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3"
|
||||
android:paddingTop="20dp"
|
||||
android:gravity="center" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="baseline">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1"
|
||||
android:gravity="bottom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="2"
|
||||
android:gravity="top" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3"
|
||||
android:paddingTop="20dp"
|
||||
android:gravity="center" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
android:padding="16dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_end">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignContent="stretch"
|
||||
app:alignItems="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1"
|
||||
app:layout_alignSelf="stretch" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:alignContent="stretch" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_flexGrow="1.0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2"
|
||||
app:layout_wrapBefore="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignContent="stretch" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
android:text="1"
|
||||
app:layout_flexGrow="1.0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="2"
|
||||
app:layout_wrapBefore="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="20dp"
|
||||
app:flexDirection="column">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="20dp"
|
||||
android:text="1"
|
||||
app:layout_alignSelf="center" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="100dp"
|
||||
app:flexDirection="row">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:text="1"
|
||||
app:layout_alignSelf="center" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:alignContent="flex_start"
|
||||
app:alignItems="flex_start"
|
||||
app:dividerDrawableHorizontal="@drawable/divider"
|
||||
app:showDividerHorizontal="beginning">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="90dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="90dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="90dp"
|
||||
android:text="3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text4"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="140dp"
|
||||
android:text="4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text5"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="140dp"
|
||||
android:text="5" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignContent="flex_start"
|
||||
app:alignItems="flex_start"
|
||||
app:dividerDrawableVertical="@drawable/divider"
|
||||
app:showDividerVertical="beginning">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text4"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text5"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="5" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="stretch"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="500dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="stretch"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="500dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="6dp"
|
||||
android:layout_height="300dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This layout verifies the case where the first view's visibility is gone and the second view is
|
||||
in the next flex line by setting the layout_wrapBefore="true"
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="stretch"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2"
|
||||
app:layout_wrapBefore="true"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3"
|
||||
app:layout_wrapBefore="true"
|
||||
/>
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This layout verifies the case where the first view's visibility is gone and the second view is
|
||||
in the next flex line by setting the layout_wrapBefore="true"
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="stretch"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2"
|
||||
app:layout_wrapBefore="true"
|
||||
app:layout_flexGrow="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_wrapBefore="true" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This layout verifies the case where the first view's visibility is gone and the second view is
|
||||
in the next flex line by setting the layout_wrapBefore="true"
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="320dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="stretch"
|
||||
app:alignContent="stretch">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2"
|
||||
app:layout_wrapBefore="true"
|
||||
app:layout_flexShrink="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3"
|
||||
app:layout_flexShrink="1"
|
||||
app:layout_wrapBefore="true" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_flexBasisPercent="50%"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_flexBasisPercent="60%"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3"
|
||||
app:layout_flexGrow="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start"
|
||||
app:alignContent="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start"
|
||||
app:alignContent="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="300dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start"
|
||||
app:alignContent="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1"
|
||||
app:layout_flexShrink="0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2"
|
||||
app:layout_flexShrink="0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3"
|
||||
app:layout_flexShrink="0" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
--><!-- Set the layout_width and layout_height as wrap_content to test the behavior of
|
||||
the situation MeasureSpec.AT_MOST is set as width/height mode -->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Wrap the FlexboxLayout with a Scrollview to test
|
||||
the situation MeasureSpec.UNSPECIFIED is set as height mode -->
|
||||
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
</HorizontalScrollView>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- Wrap the FlexboxLayout with a Scrollview to test
|
||||
the situation MeasureSpec.UNSPECIFIED is set as height mode -->
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="500dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="500dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="500dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
</ScrollView>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row"
|
||||
app:justifyContent="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row"
|
||||
app:justifyContent="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/frame_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="24dp">
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="8dp"
|
||||
app:flexDirection="row"
|
||||
app:justifyContent="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="column">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="150dp"
|
||||
android:text="1"
|
||||
app:layout_maxHeight="100dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:text="2"
|
||||
app:layout_flexGrow="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="nowrap" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
android:text="1"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_maxHeight="150dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="100dp"
|
||||
app:layout_flexGrow="1"
|
||||
android:text="2" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_maxWidth="100dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2"
|
||||
app:layout_flexGrow="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexWrap="nowrap" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_maxWidth="150dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_flexGrow="1"
|
||||
android:text="2" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="nowrap" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:text="1"
|
||||
app:layout_minHeight="150dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:text="3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:text="4" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexDirection="column">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_minHeight="100dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:text="2"
|
||||
app:layout_flexGrow="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp"
|
||||
app:flexWrap="nowrap" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_minWidth="150dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text4"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout android:id="@+id/flexbox_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="400dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_minWidth="100dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2"
|
||||
app:layout_flexGrow="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_order="2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2"
|
||||
app:layout_order="-1" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="3"
|
||||
app:layout_order="0" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="4" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="row_reverse"
|
||||
app:justifyContent="center"
|
||||
app:alignContent="center"
|
||||
app:alignItems="center">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_order="2"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_alignSelf="stretch" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="360dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="stretch"
|
||||
app:alignContent="stretch" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="300dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text4"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="4" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text5"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="5" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="300dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="1"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="2"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="120dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="360dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="160dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="160dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="160dp"
|
||||
android:visibility="gone"
|
||||
android:text="3" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="160dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:text="3" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="2"
|
||||
app:layout_wrapBefore="true" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3"
|
||||
app:layout_wrapBefore="true" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_margin="32dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="360dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="280dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_margin="32dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:justifyContent="flex_end" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:text="1"
|
||||
app:layout_flexBasisPercent="50%"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_flexShrink="0" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="nowrap"
|
||||
app:justifyContent="flex_end" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:text="1"
|
||||
app:layout_flexShrink="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="12dp"
|
||||
android:layout_height="100dp"
|
||||
android:text="2"
|
||||
app:layout_flexShrink="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexWrap="wrap"
|
||||
app:justifyContent="flex_end" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:text="test"
|
||||
app:layout_flexBasisPercent="50%"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_flexShrink="0" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:flexWrap="nowrap"
|
||||
app:justifyContent="flex_end" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:text="test1"
|
||||
app:layout_flexShrink="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="12dp"
|
||||
android:text="test2"
|
||||
app:layout_flexShrink="1" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="32dp"
|
||||
app:flexDirection="row"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="360dp"
|
||||
android:padding="32dp"
|
||||
app:flexDirection="column"
|
||||
app:flexWrap="wrap"
|
||||
app:alignItems="flex_start">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="280dp"
|
||||
android:text="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="30dp"
|
||||
android:text="2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text3"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:text="3" />
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:flexDirection="column"
|
||||
app:alignItems="flex_start" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:text="1"
|
||||
app:layout_flexGrow="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:text="2-some long text"
|
||||
app:layout_flexGrow="1" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<com.google.android.flexbox.FlexboxLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/flexbox_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:alignItems="flex_start" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="1"
|
||||
app:layout_flexGrow="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="2-some long text"
|
||||
app:layout_flexGrow="1" />
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<!-- Some APIs in espresso requires the view being performed is at least 90% visible to the
|
||||
user, using the small width so that low resolution devices are covered-->
|
||||
<androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerview"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="240dp" />
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerview"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="400dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
app:reverseLayout="true"
|
||||
app:stackFromEnd="true"
|
||||
app:layoutManager="com.google.android.flexbox.FlexboxLayoutManager" />
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2016 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/textview"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="80dp" />
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2017 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<!-- The nested RecyclerViews tests verify the wrap_content behavior -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/recyclerview_inner"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp" />
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2017 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<!-- The nested RecyclerViews tests verify the wrap_content behavior -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/recyclerview_inner"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2017 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/textview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp" />
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2017 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<!-- Some APIs in espresso requires the view being performed is at least 90% visible to the
|
||||
user, using the small width so that low resolution devices are covered-->
|
||||
<FrameLayout android:id="@+id/container"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="240dp">
|
||||
<androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerview"
|
||||
android:layout_width="600dp"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
~ Copyright 2017 Google Inc. All rights reserved.
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<!-- Some APIs in espresso requires the view being performed is at least 90% visible to the
|
||||
user, using the small width so that low resolution devices are covered-->
|
||||
<FrameLayout android:id="@+id/container"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="320dp"
|
||||
android:layout_height="240dp">
|
||||
<androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="600dp"/>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!--
|
||||
Copyright 2017 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<string name="item_description">%1$s - %2$s</string>
|
||||
</resources>
|
||||
17
OnTime_Merchant_live/lib/flexbox-layout/flexbox/src/main/AndroidManifest.xml
Executable file
17
OnTime_Merchant_live/lib/flexbox-layout/flexbox/src/main/AndroidManifest.xml
Executable file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2016 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<manifest package="com.google.android.flexbox" />
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
/** This attribute controls the alignment of the flex lines in the flex container. */
|
||||
@IntDef({AlignContent.FLEX_START, AlignContent.FLEX_END, AlignContent.CENTER,
|
||||
AlignContent.SPACE_BETWEEN, AlignContent.SPACE_AROUND, AlignContent.STRETCH})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AlignContent {
|
||||
|
||||
/** Flex lines are packed to the start of the flex container. */
|
||||
int FLEX_START = 0;
|
||||
|
||||
/** Flex lines are packed to the end of the flex container. */
|
||||
int FLEX_END = 1;
|
||||
|
||||
/** Flex lines are centered in the flex container. */
|
||||
int CENTER = 2;
|
||||
|
||||
/**
|
||||
* Flex lines are evenly distributed in the flex container. The first flex line is
|
||||
* placed at the start of the flex container, the last flex line is placed at the
|
||||
* end of the flex container.
|
||||
*/
|
||||
int SPACE_BETWEEN = 3;
|
||||
|
||||
/**
|
||||
* Flex lines are evenly distributed in the flex container with the same amount of spaces
|
||||
* between the flex lines.
|
||||
*/
|
||||
int SPACE_AROUND = 4;
|
||||
|
||||
/**
|
||||
* Flex lines are stretched to fill the remaining space along the cross axis.
|
||||
*/
|
||||
int STRETCH = 5;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
/** This attribute controls the alignment along the cross axis. */
|
||||
@IntDef({AlignItems.FLEX_START, AlignItems.FLEX_END, AlignItems.CENTER,
|
||||
AlignItems.BASELINE, AlignItems.STRETCH})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AlignItems {
|
||||
|
||||
/** Flex item's edge is placed on the cross start line. */
|
||||
int FLEX_START = 0;
|
||||
|
||||
/** Flex item's edge is placed on the cross end line. */
|
||||
int FLEX_END = 1;
|
||||
|
||||
/** Flex item's edge is centered along the cross axis. */
|
||||
int CENTER = 2;
|
||||
|
||||
/** Flex items are aligned based on their text's baselines. */
|
||||
int BASELINE = 3;
|
||||
|
||||
/** Flex items are stretched to fill the flex line's cross size. */
|
||||
int STRETCH = 4;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
/**
|
||||
* This attribute controls the alignment along the cross axis.
|
||||
* The alignment in the same direction can be determined by the {@link AlignItems} attribute in the
|
||||
* parent, but if this is set to other than {@link AlignSelf#AUTO},
|
||||
* the cross axis alignment is overridden for this child.
|
||||
*/
|
||||
@IntDef({AlignItems.FLEX_START, AlignItems.FLEX_END, AlignItems.CENTER,
|
||||
AlignItems.BASELINE, AlignItems.STRETCH, AlignSelf.AUTO})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AlignSelf {
|
||||
|
||||
/**
|
||||
* The default value for the AlignSelf attribute, which means use the inherit
|
||||
* the {@link AlignItems} attribute from its parent.
|
||||
*/
|
||||
int AUTO = -1;
|
||||
|
||||
/** This item's edge is placed on the cross start line. */
|
||||
int FLEX_START = AlignItems.FLEX_START;
|
||||
|
||||
/** This item's edge is placed on the cross end line. */
|
||||
int FLEX_END = AlignItems.FLEX_END;
|
||||
|
||||
/** This item's edge is centered along the cross axis. */
|
||||
int CENTER = AlignItems.CENTER;
|
||||
|
||||
/** This items is aligned based on their text's baselines. */
|
||||
int BASELINE = AlignItems.BASELINE;
|
||||
|
||||
/** This item is stretched to fill the flex line's cross size. */
|
||||
int STRETCH = AlignItems.STRETCH;
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An interface that has the common behavior as the flex container such as {@link FlexboxLayout}
|
||||
* and {@link FlexboxLayoutManager}.
|
||||
*/
|
||||
interface FlexContainer {
|
||||
|
||||
int NOT_SET = -1;
|
||||
|
||||
/**
|
||||
* @return the number of flex items contained in the flex container.
|
||||
*/
|
||||
int getFlexItemCount();
|
||||
|
||||
/**
|
||||
* Returns a flex item as a View at the given index.
|
||||
*
|
||||
* @param index the index
|
||||
* @return the view at the index
|
||||
*/
|
||||
View getFlexItemAt(int index);
|
||||
|
||||
/**
|
||||
* Returns a flex item as a View, which is reordered by taking the order attribute into
|
||||
* account.
|
||||
*
|
||||
* @param index the index of the view
|
||||
* @return the reordered view, which order attribute is taken into account.
|
||||
* If the index is negative or out of bounds of the number of contained views,
|
||||
* returns {@code null}.
|
||||
* @see FlexItem#getOrder()
|
||||
*/
|
||||
View getReorderedFlexItemAt(int index);
|
||||
|
||||
/**
|
||||
* Adds the view to the flex container as a flex item.
|
||||
*
|
||||
* @param view the view to be added
|
||||
*/
|
||||
void addView(View view);
|
||||
|
||||
/**
|
||||
* Adds the view to the specified index of the flex container.
|
||||
*
|
||||
* @param view the view to be added
|
||||
* @param index the index for the view to be added
|
||||
*/
|
||||
void addView(View view, int index);
|
||||
|
||||
/**
|
||||
* Removes all the views contained in the flex container.
|
||||
*/
|
||||
void removeAllViews();
|
||||
|
||||
/**
|
||||
* Removes the view at the specified index.
|
||||
*
|
||||
* @param index the index from which the view is removed.
|
||||
*/
|
||||
void removeViewAt(int index);
|
||||
|
||||
/**
|
||||
* @return the flex direction attribute of the flex container.
|
||||
* @see FlexDirection
|
||||
*/
|
||||
@FlexDirection
|
||||
int getFlexDirection();
|
||||
|
||||
/**
|
||||
* Sets the given flex direction attribute to the flex container.
|
||||
*
|
||||
* @param flexDirection the flex direction value
|
||||
* @see FlexDirection
|
||||
*/
|
||||
void setFlexDirection(@FlexDirection int flexDirection);
|
||||
|
||||
/**
|
||||
* @return the flex wrap attribute of the flex container.
|
||||
* @see FlexWrap
|
||||
*/
|
||||
@FlexWrap
|
||||
int getFlexWrap();
|
||||
|
||||
/**
|
||||
* Sets the given flex wrap attribute to the flex container.
|
||||
*
|
||||
* @param flexWrap the flex wrap value
|
||||
* @see FlexWrap
|
||||
*/
|
||||
void setFlexWrap(@FlexWrap int flexWrap);
|
||||
|
||||
/**
|
||||
* @return the justify content attribute of the flex container.
|
||||
* @see JustifyContent
|
||||
*/
|
||||
@JustifyContent
|
||||
int getJustifyContent();
|
||||
|
||||
/**
|
||||
* Sets the given justify content attribute to the flex container.
|
||||
*
|
||||
* @param justifyContent the justify content value
|
||||
* @see JustifyContent
|
||||
*/
|
||||
void setJustifyContent(@JustifyContent int justifyContent);
|
||||
|
||||
/**
|
||||
* @return the align content attribute of the flex container.
|
||||
* @see AlignContent
|
||||
*/
|
||||
@AlignContent
|
||||
int getAlignContent();
|
||||
|
||||
/**
|
||||
* Sets the given align content attribute to the flex container.
|
||||
*
|
||||
* @param alignContent the align content value
|
||||
*/
|
||||
void setAlignContent(@AlignContent int alignContent);
|
||||
|
||||
/**
|
||||
* @return the align items attribute of the flex container.
|
||||
* @see AlignItems
|
||||
*/
|
||||
@AlignItems
|
||||
int getAlignItems();
|
||||
|
||||
/**
|
||||
* Sets the given align items attribute to the flex container.
|
||||
*
|
||||
* @param alignItems the align items value
|
||||
* @see AlignItems
|
||||
*/
|
||||
void setAlignItems(@AlignItems int alignItems);
|
||||
|
||||
/**
|
||||
* @return the flex lines composing this flex container. The overridden method should return a
|
||||
* copy of the original list excluding a dummy flex line (flex line that doesn't have any flex
|
||||
* items in it but used for the alignment along the cross axis) so that any changes of the
|
||||
* returned list are not reflected to the original list.
|
||||
*/
|
||||
List<FlexLine> getFlexLines();
|
||||
|
||||
/**
|
||||
* Returns true if the main axis is horizontal, false otherwise.
|
||||
*
|
||||
* @return true if the main axis is horizontal, false otherwise
|
||||
*/
|
||||
boolean isMainAxisDirectionHorizontal();
|
||||
|
||||
/**
|
||||
* Returns the length of decoration (such as dividers) of the flex item along the main axis.
|
||||
*
|
||||
* @param view the view from which the length of the decoration is retrieved
|
||||
* @param index the absolute index of the flex item within the flex container
|
||||
* @param indexInFlexLine the relative index of the flex item within the flex line
|
||||
* @return the length of the decoration. Note that the length of the flex item itself is not
|
||||
* included in the result.
|
||||
*/
|
||||
int getDecorationLengthMainAxis(View view, int index, int indexInFlexLine);
|
||||
|
||||
/**
|
||||
* Returns the length of decoration (such as dividers) of the flex item along the cross axis.
|
||||
*
|
||||
* @param view the view from which the length of the decoration is retrieved
|
||||
* @return the length of the decoration. Note that the length of the flex item itself is not
|
||||
* included in the result.
|
||||
*/
|
||||
int getDecorationLengthCrossAxis(View view);
|
||||
|
||||
/**
|
||||
* @return the top padding of the flex container.
|
||||
*/
|
||||
int getPaddingTop();
|
||||
|
||||
/**
|
||||
* @return the left padding of the flex container.
|
||||
*/
|
||||
int getPaddingLeft();
|
||||
|
||||
/**
|
||||
* @return the right padding of the flex container.
|
||||
*/
|
||||
int getPaddingRight();
|
||||
|
||||
/**
|
||||
* @return the bottom padding of the flex container.
|
||||
*/
|
||||
int getPaddingBottom();
|
||||
|
||||
/**
|
||||
* @return the start padding of this view depending on its resolved layout direction.
|
||||
*/
|
||||
int getPaddingStart();
|
||||
|
||||
/**
|
||||
* @return the end padding of this view depending on its resolved layout direction.
|
||||
*/
|
||||
int getPaddingEnd();
|
||||
|
||||
/**
|
||||
* Returns the child measure spec for its width.
|
||||
*
|
||||
* @param widthSpec the measure spec for the width imposed by the parent
|
||||
* @param padding the padding along the width for the parent
|
||||
* @param childDimension the value of the child dimension
|
||||
*/
|
||||
int getChildWidthMeasureSpec(int widthSpec, int padding, int childDimension);
|
||||
|
||||
/**
|
||||
* Returns the child measure spec for its height.
|
||||
*
|
||||
* @param heightSpec the measure spec for the height imposed by the parent
|
||||
* @param padding the padding along the height for the parent
|
||||
* @param childDimension the value of the child dimension
|
||||
*/
|
||||
int getChildHeightMeasureSpec(int heightSpec, int padding, int childDimension);
|
||||
|
||||
/**
|
||||
* @return the largest main size of all flex lines including decorator lengths.
|
||||
*/
|
||||
int getLargestMainSize();
|
||||
|
||||
/**
|
||||
* @return the sum of the cross sizes of all flex lines including decorator lengths.
|
||||
*/
|
||||
int getSumOfCrossSize();
|
||||
|
||||
/**
|
||||
* Callback when a new flex item is added to the current container
|
||||
*
|
||||
* @param view the view as a flex item which is added
|
||||
* @param index the absolute index of the flex item added
|
||||
* @param indexInFlexLine the relative index of the flex item added within the flex line
|
||||
* @param flexLine the flex line where the new flex item is added
|
||||
*/
|
||||
void onNewFlexItemAdded(View view, int index, int indexInFlexLine, FlexLine flexLine);
|
||||
|
||||
/**
|
||||
* Callback when a new flex line is added to the current container
|
||||
*
|
||||
* @param flexLine the new added flex line
|
||||
*/
|
||||
void onNewFlexLineAdded(FlexLine flexLine);
|
||||
|
||||
/**
|
||||
* Sets the list of the flex lines that compose the flex container to the one received as an
|
||||
* argument.
|
||||
*
|
||||
* @param flexLines the list of flex lines
|
||||
*/
|
||||
void setFlexLines(List<FlexLine> flexLines);
|
||||
|
||||
/**
|
||||
* @return the current value of the maximum number of flex lines. If not set, {@link #NOT_SET}
|
||||
* is returned.
|
||||
*/
|
||||
int getMaxLine();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param maxLine the int value, which specifies the maximum number of flex lines
|
||||
*/
|
||||
void setMaxLine(int maxLine);
|
||||
|
||||
/**
|
||||
* @return the list of the flex lines including dummy flex lines (flex line that doesn't have
|
||||
* any flex items in it but used for the alignment along the cross axis), which aren't included
|
||||
* in the {@link FlexContainer#getFlexLines()}.
|
||||
*/
|
||||
List<FlexLine> getFlexLinesInternal();
|
||||
|
||||
/**
|
||||
* Update the view cache in the flex container.
|
||||
*
|
||||
* @param position the position of the view to be updated
|
||||
* @param view the view instance
|
||||
*/
|
||||
void updateViewCache(int position, View view);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
/**
|
||||
* The direction children items are placed inside the flex container, it determines the
|
||||
* direction of the main axis (and the cross axis, perpendicular to the main axis).
|
||||
*/
|
||||
@IntDef({FlexDirection.ROW, FlexDirection.ROW_REVERSE, FlexDirection.COLUMN,
|
||||
FlexDirection.COLUMN_REVERSE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FlexDirection {
|
||||
|
||||
/**
|
||||
* Main axis direction -> horizontal. Main start to
|
||||
* main end -> Left to right (in LTR languages).
|
||||
* Cross start to cross end -> Top to bottom
|
||||
*/
|
||||
int ROW = 0;
|
||||
|
||||
/**
|
||||
* Main axis direction -> horizontal. Main start
|
||||
* to main end -> Right to left (in LTR languages). Cross start to cross end ->
|
||||
* Top to bottom.
|
||||
*/
|
||||
int ROW_REVERSE = 1;
|
||||
|
||||
/**
|
||||
* Main axis direction -> vertical. Main start
|
||||
* to main end -> Top to bottom. Cross start to cross end ->
|
||||
* Left to right (In LTR languages).
|
||||
*/
|
||||
int COLUMN = 2;
|
||||
|
||||
/**
|
||||
* Main axis direction -> vertical. Main start
|
||||
* to main end -> Bottom to top. Cross start to cross end -> Left to right
|
||||
* (In LTR languages)
|
||||
*/
|
||||
int COLUMN_REVERSE = 3;
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import android.os.Parcelable;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* An interface that has the common behavior as a flex item contained in a flex container.
|
||||
* Known classes that implement this interface are {@link FlexboxLayout.LayoutParams} and
|
||||
* {@link FlexboxLayoutManager.LayoutParams}.
|
||||
*/
|
||||
interface FlexItem extends Parcelable {
|
||||
|
||||
/** The default value for the order attribute */
|
||||
int ORDER_DEFAULT = 1;
|
||||
|
||||
/** The default value for the flex grow attribute */
|
||||
float FLEX_GROW_DEFAULT = 0f;
|
||||
|
||||
/** The default value for the flex shrink attribute */
|
||||
float FLEX_SHRINK_DEFAULT = 1f;
|
||||
|
||||
/** The value representing the flex shrink attribute is not set */
|
||||
float FLEX_SHRINK_NOT_SET = 0f;
|
||||
|
||||
/** The default value for the flex basis percent attribute */
|
||||
float FLEX_BASIS_PERCENT_DEFAULT = -1f;
|
||||
|
||||
/** The maximum size of the max width and max height attributes */
|
||||
int MAX_SIZE = Integer.MAX_VALUE & View.MEASURED_SIZE_MASK;
|
||||
|
||||
/**
|
||||
* @return the width attribute of the flex item.
|
||||
*
|
||||
* The attribute is about how wide the view wants to be. Can be one of the
|
||||
* constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Sets the width attribute of the flex item.
|
||||
*
|
||||
* @param width the width attribute. Can be one of the
|
||||
* constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
|
||||
*/
|
||||
void setWidth(int width);
|
||||
|
||||
/**
|
||||
* @return the height attribute of the flex item.
|
||||
*
|
||||
* The attribute is about how wide the view wants to be. Can be one of the
|
||||
* constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* Sets the height attribute of the flex item.
|
||||
*
|
||||
* @param height the height attribute. Can be one of the
|
||||
* constants MATCH_PARENT(-1) or WRAP_CONTENT(-2), or an exact size.
|
||||
*/
|
||||
void setHeight(int height);
|
||||
|
||||
/**
|
||||
* @return the order attribute of the flex item.
|
||||
*
|
||||
* The attribute can change the ordering of the children views are laid out.
|
||||
* By default, children are displayed and laid out in the same order as they appear in the
|
||||
* layout XML. If not specified, {@link #ORDER_DEFAULT} is set as a default value.
|
||||
*/
|
||||
int getOrder();
|
||||
|
||||
/**
|
||||
* Sets the order attribute to the flex item
|
||||
*
|
||||
* @param order the order attribute
|
||||
*/
|
||||
void setOrder(int order);
|
||||
|
||||
/**
|
||||
* @return the flex grow attribute of the flex item
|
||||
*
|
||||
* The attribute determines how much this child will grow if positive free space is
|
||||
* distributed relative to the rest of other flex items included in the same flex line.
|
||||
* If not specified, {@link #FLEX_GROW_DEFAULT} is set as a default value.
|
||||
*/
|
||||
float getFlexGrow();
|
||||
|
||||
/**
|
||||
* Sets the flex grow attribute to the flex item
|
||||
*
|
||||
* @param flexGrow the flex grow attribute
|
||||
*/
|
||||
void setFlexGrow(float flexGrow);
|
||||
|
||||
/**
|
||||
* @return the flex shrink attribute of the flex item
|
||||
*
|
||||
* The attribute determines how much this child will shrink if negative free space is
|
||||
* distributed relative to the rest of other flex items included in the same flex line.
|
||||
* If not specified, {@link #FLEX_SHRINK_DEFAULT} is set as a default value.
|
||||
*/
|
||||
float getFlexShrink();
|
||||
|
||||
/**
|
||||
* Sets the flex shrink attribute to the flex item
|
||||
*
|
||||
* @param flexShrink the flex shrink attribute
|
||||
*/
|
||||
void setFlexShrink(float flexShrink);
|
||||
|
||||
/**
|
||||
* @return the align self attribute of the flex item
|
||||
*
|
||||
* The attribute determines the alignment along the cross axis (perpendicular to the
|
||||
* main axis). The alignment in the same direction can be determined by the
|
||||
* align items attribute in the parent, but if this is set to other than
|
||||
* {@link AlignSelf#AUTO}, the cross axis alignment is overridden for this child.
|
||||
* The value needs to be one of the values in ({@link AlignSelf#AUTO},
|
||||
* {@link AlignItems#STRETCH}, {@link AlignItems#FLEX_START}, {@link
|
||||
* AlignItems#FLEX_END}, {@link AlignItems#CENTER}, or {@link AlignItems#BASELINE}).
|
||||
* If not specified, {@link AlignSelf#AUTO} is set as a default value.
|
||||
*/
|
||||
@AlignSelf
|
||||
int getAlignSelf();
|
||||
|
||||
/**
|
||||
* Sets the align self attribute to the flex item
|
||||
*
|
||||
* @param alignSelf the order attribute
|
||||
*/
|
||||
void setAlignSelf(@AlignSelf int alignSelf);
|
||||
|
||||
/**
|
||||
* @return the minimum width attribute of the flex item
|
||||
*
|
||||
* The attribute determines the minimum width the child can shrink to.
|
||||
*/
|
||||
int getMinWidth();
|
||||
|
||||
/**
|
||||
* Sets the minimum width attribute to the flex item
|
||||
*
|
||||
* @param minWidth the order attribute
|
||||
*/
|
||||
void setMinWidth(int minWidth);
|
||||
|
||||
/**
|
||||
* @return the minimum height attribute of the flex item
|
||||
*
|
||||
* The attribute determines the minimum height the child can shrink to.
|
||||
*/
|
||||
int getMinHeight();
|
||||
|
||||
/**
|
||||
* Sets the minimum height attribute to the flex item
|
||||
*
|
||||
* @param minHeight the order attribute
|
||||
*/
|
||||
void setMinHeight(int minHeight);
|
||||
|
||||
/**
|
||||
* @return the maximum width attribute of the flex item
|
||||
*
|
||||
* The attribute determines the maximum width the child can expand to.
|
||||
*/
|
||||
int getMaxWidth();
|
||||
|
||||
/**
|
||||
* Sets the maximum width attribute to the flex item
|
||||
*
|
||||
* @param maxWidth the order attribute
|
||||
*/
|
||||
void setMaxWidth(int maxWidth);
|
||||
|
||||
/**
|
||||
* @return the maximum height attribute of the flex item
|
||||
*/
|
||||
int getMaxHeight();
|
||||
|
||||
/**
|
||||
* Sets the maximum height attribute to the flex item
|
||||
*
|
||||
* @param maxHeight the order attribute
|
||||
*/
|
||||
void setMaxHeight(int maxHeight);
|
||||
|
||||
/**
|
||||
* @return the wrapBefore attribute of the flex item
|
||||
*
|
||||
* The attribute forces a flex line wrapping. i.e. if this is set to {@code true} for a
|
||||
* flex item, the item will become the first item of the new flex line. (A wrapping happens
|
||||
* regardless of the flex items being processed in the the previous flex line)
|
||||
* This attribute is ignored if the flex_wrap attribute is set as nowrap.
|
||||
* The equivalent attribute isn't defined in the original CSS Flexible Box Module
|
||||
* specification, but having this attribute is useful for Android developers to flatten
|
||||
* the layouts when building a grid like layout or for a situation where developers want
|
||||
* to put a new flex line to make a semantic difference from the previous one, etc.
|
||||
*/
|
||||
boolean isWrapBefore();
|
||||
|
||||
/**
|
||||
* Sets the wrapBefore attribute to the flex item
|
||||
*
|
||||
* @param wrapBefore the order attribute
|
||||
*/
|
||||
void setWrapBefore(boolean wrapBefore);
|
||||
|
||||
/**
|
||||
* @return the flexBasisPercent attribute of the flex item
|
||||
*
|
||||
* The attribute determines the initial flex item length in a fraction format relative to its
|
||||
* parent.
|
||||
* The initial main size of this child View is trying to be expanded as the specified
|
||||
* fraction against the parent main size.
|
||||
* If this value is set, the length specified from layout_width
|
||||
* (or layout_height) is overridden by the calculated value from this attribute.
|
||||
* This attribute is only effective when the parent's MeasureSpec mode is
|
||||
* MeasureSpec.EXACTLY. The default value is -1, which means not set.
|
||||
*/
|
||||
float getFlexBasisPercent();
|
||||
|
||||
/**
|
||||
* Sets the flex basis percent attribute to the flex item
|
||||
*
|
||||
* @param flexBasisPercent the order attribute
|
||||
*/
|
||||
void setFlexBasisPercent(float flexBasisPercent);
|
||||
|
||||
/**
|
||||
* @return the left margin of the flex item.
|
||||
*/
|
||||
int getMarginLeft();
|
||||
|
||||
/**
|
||||
* @return the top margin of the flex item.
|
||||
*/
|
||||
int getMarginTop();
|
||||
|
||||
/**
|
||||
* @return the right margin of the flex item.
|
||||
*/
|
||||
int getMarginRight();
|
||||
|
||||
/**
|
||||
* @return the bottom margin of the flex item.
|
||||
*/
|
||||
int getMarginBottom();
|
||||
|
||||
/**
|
||||
* @return the start margin of the flex item depending on its resolved layout direction.
|
||||
*/
|
||||
int getMarginStart();
|
||||
|
||||
/**
|
||||
* @return the end margin of the flex item depending on its resolved layout direction.
|
||||
*/
|
||||
int getMarginEnd();
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Holds properties related to a single flex line. This class is not expected to be changed outside
|
||||
* of the {@link FlexboxLayout}, thus only exposing the getter methods that may be useful for
|
||||
* other classes using the {@link FlexboxLayout}.
|
||||
*/
|
||||
public class FlexLine {
|
||||
|
||||
FlexLine() {
|
||||
}
|
||||
|
||||
int mLeft = Integer.MAX_VALUE;
|
||||
|
||||
int mTop = Integer.MAX_VALUE;
|
||||
|
||||
int mRight = Integer.MIN_VALUE;
|
||||
|
||||
int mBottom = Integer.MIN_VALUE;
|
||||
|
||||
/** @see #getMainSize() */
|
||||
int mMainSize;
|
||||
|
||||
/**
|
||||
* The sum of the lengths of dividers along the main axis. This value should be lower
|
||||
* than the value of {@link #mMainSize}.
|
||||
*/
|
||||
int mDividerLengthInMainSize;
|
||||
|
||||
/** @see #getCrossSize() */
|
||||
int mCrossSize;
|
||||
|
||||
/** @see #getItemCount() */
|
||||
int mItemCount;
|
||||
|
||||
/** Holds the count of the views whose visibilities are gone */
|
||||
int mGoneItemCount;
|
||||
|
||||
/** @see #getTotalFlexGrow() */
|
||||
float mTotalFlexGrow;
|
||||
|
||||
/** @see #getTotalFlexShrink() */
|
||||
float mTotalFlexShrink;
|
||||
|
||||
/**
|
||||
* The largest value of the individual child's baseline (obtained by View#getBaseline()
|
||||
* if the {@link FlexContainer#getAlignItems()} value is not {@link AlignItems#BASELINE}
|
||||
* or the flex direction is vertical, this value is not used.
|
||||
* If the alignment direction is from the bottom to top,
|
||||
* (e.g. flexWrap == WRAP_REVERSE and flexDirection == ROW)
|
||||
* store this value from the distance from the bottom of the view minus baseline.
|
||||
* (Calculated as view.getMeasuredHeight() - view.getBaseline - LayoutParams.bottomMargin)
|
||||
*/
|
||||
int mMaxBaseline;
|
||||
|
||||
/**
|
||||
* The sum of the cross size used before this flex line.
|
||||
*/
|
||||
int mSumCrossSizeBefore;
|
||||
|
||||
/**
|
||||
* Store the indices of the children views whose alignSelf property is stretch.
|
||||
* The stored indices are the absolute indices including all children in the Flexbox,
|
||||
* not the relative indices in this flex line.
|
||||
*/
|
||||
List<Integer> mIndicesAlignSelfStretch = new ArrayList<>();
|
||||
|
||||
int mFirstIndex;
|
||||
|
||||
int mLastIndex;
|
||||
|
||||
/**
|
||||
* Set to true if any {@link FlexItem}s in this line have {@link FlexItem#getFlexGrow()}
|
||||
* attributes set (have the value other than {@link FlexItem#FLEX_GROW_DEFAULT})
|
||||
*/
|
||||
boolean mAnyItemsHaveFlexGrow;
|
||||
|
||||
/**
|
||||
* Set to true if any {@link FlexItem}s in this line have {@link FlexItem#getFlexShrink()}
|
||||
* attributes set (have the value other than {@link FlexItem#FLEX_SHRINK_NOT_SET})
|
||||
*/
|
||||
boolean mAnyItemsHaveFlexShrink;
|
||||
|
||||
/**
|
||||
* @return the size of the flex line in pixels along the main axis of the flex container.
|
||||
*/
|
||||
public int getMainSize() {
|
||||
return mMainSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size of the flex line in pixels along the cross axis of the flex container.
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public int getCrossSize() {
|
||||
return mCrossSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count of the views contained in this flex line.
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public int getItemCount() {
|
||||
return mItemCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the count of the views whose visibilities are not gone in this flex line.
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public int getItemCountNotGone() {
|
||||
return mItemCount - mGoneItemCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sum of the flexGrow properties of the children included in this flex line
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public float getTotalFlexGrow() {
|
||||
return mTotalFlexGrow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sum of the flexShrink properties of the children included in this flex line
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public float getTotalFlexShrink() {
|
||||
return mTotalFlexShrink;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the first view's index included in this flex line.
|
||||
*/
|
||||
public int getFirstIndex() {
|
||||
return mFirstIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the position of the flex line from the contained view.
|
||||
*
|
||||
* @param view the view contained in this flex line
|
||||
* @param leftDecoration the length of the decoration on the left of the view
|
||||
* @param topDecoration the length of the decoration on the top of the view
|
||||
* @param rightDecoration the length of the decoration on the right of the view
|
||||
* @param bottomDecoration the length of the decoration on the bottom of the view
|
||||
*/
|
||||
void updatePositionFromView(View view, int leftDecoration, int topDecoration,
|
||||
int rightDecoration, int bottomDecoration) {
|
||||
FlexItem flexItem = (FlexItem) view.getLayoutParams();
|
||||
mLeft = Math.min(mLeft, view.getLeft() - flexItem.getMarginLeft() - leftDecoration);
|
||||
mTop = Math.min(mTop, view.getTop() - flexItem.getMarginTop() - topDecoration);
|
||||
mRight = Math.max(mRight, view.getRight() + flexItem.getMarginRight() + rightDecoration);
|
||||
mBottom = Math
|
||||
.max(mBottom, view.getBottom() + flexItem.getMarginBottom() + bottomDecoration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
/**
|
||||
* This attribute controls whether the flex container is single-line or multi-line, and the
|
||||
* direction of the cross axis.
|
||||
*/
|
||||
@IntDef({FlexWrap.NOWRAP, FlexWrap.WRAP, FlexWrap.WRAP_REVERSE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FlexWrap {
|
||||
|
||||
/** The flex container is single-line. */
|
||||
int NOWRAP = 0;
|
||||
|
||||
/** The flex container is multi-line. */
|
||||
int WRAP = 1;
|
||||
|
||||
/**
|
||||
* The flex container is multi-line. The direction of the
|
||||
* cross axis is opposed to the direction as the {@link #WRAP}
|
||||
*/
|
||||
int WRAP_REVERSE = 2;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.flexbox;
|
||||
|
||||
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* {@link RecyclerView.ItemDecoration} implementation that can be used as item decorations between
|
||||
* view holders within the {@link FlexboxLayoutManager}.
|
||||
*
|
||||
* Orientation for the decoration can be either of:
|
||||
* <ul>
|
||||
* <li>Horizontal (setOrientation(HORIZONTAL)</li>
|
||||
* <li>Vertical (setOrientation(VERTICAL)</li>
|
||||
* <li>Both orientation (setOrientation(BOTH)</li>
|
||||
* </ul>.
|
||||
* The default value is set to both.
|
||||
*/
|
||||
public class FlexboxItemDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
public static final int HORIZONTAL = 1;
|
||||
public static final int VERTICAL = 1 << 1;
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public static final int BOTH = HORIZONTAL | VERTICAL;
|
||||
|
||||
private static final int[] LIST_DIVIDER_ATTRS = new int[]{android.R.attr.listDivider};
|
||||
|
||||
private Drawable mDrawable;
|
||||
|
||||
private int mOrientation;
|
||||
|
||||
public FlexboxItemDecoration(Context context) {
|
||||
final TypedArray a = context.obtainStyledAttributes(LIST_DIVIDER_ATTRS);
|
||||
mDrawable = a.getDrawable(0);
|
||||
a.recycle();
|
||||
setOrientation(BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the drawable used as the item decoration.
|
||||
* If the drawable is not set, the default list divider is used as the
|
||||
* item decoration.
|
||||
*/
|
||||
public void setDrawable(Drawable drawable) {
|
||||
if (drawable == null) {
|
||||
throw new IllegalArgumentException("Drawable cannot be null.");
|
||||
}
|
||||
mDrawable = drawable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the orientation for the decoration.
|
||||
* Orientation for the decoration can be either of:
|
||||
* <ul>
|
||||
* <li>Horizontal (setOrientation(HORIZONTAL)</li>
|
||||
* <li>Vertical (setOrientation(VERTICAL)</li>
|
||||
* <li>Both orientation (setOrientation(BOTH)</li>
|
||||
* </ul>.
|
||||
*/
|
||||
public void setOrientation(int orientation) {
|
||||
mOrientation = orientation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(
|
||||
@NonNull Canvas canvas,
|
||||
@NonNull RecyclerView parent,
|
||||
@NonNull RecyclerView.State state) {
|
||||
drawHorizontalDecorations(canvas, parent);
|
||||
drawVerticalDecorations(canvas, parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getItemOffsets(
|
||||
@NonNull Rect outRect,
|
||||
@NonNull View view,
|
||||
RecyclerView parent,
|
||||
@NonNull RecyclerView.State state) {
|
||||
int position = parent.getChildAdapterPosition(view);
|
||||
if (position == 0) {
|
||||
return;
|
||||
}
|
||||
if (!needsHorizontalDecoration() && !needsVerticalDecoration()) {
|
||||
outRect.set(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
FlexboxLayoutManager layoutManager = (FlexboxLayoutManager) parent.getLayoutManager();
|
||||
List<FlexLine> flexLines = layoutManager.getFlexLines();
|
||||
int flexDirection = layoutManager.getFlexDirection();
|
||||
setOffsetAlongMainAxis(outRect, position, layoutManager, flexLines, flexDirection);
|
||||
setOffsetAlongCrossAxis(outRect, position, layoutManager, flexLines);
|
||||
}
|
||||
|
||||
private void setOffsetAlongCrossAxis(Rect outRect, int position,
|
||||
FlexboxLayoutManager layoutManager, List<FlexLine> flexLines) {
|
||||
if (flexLines.size() == 0) {
|
||||
return;
|
||||
}
|
||||
int flexLineIndex = layoutManager.getPositionToFlexLineIndex(position);
|
||||
if (flexLineIndex == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (layoutManager.isMainAxisDirectionHorizontal()) {
|
||||
if (!needsHorizontalDecoration()) {
|
||||
outRect.top = 0;
|
||||
outRect.bottom = 0;
|
||||
return;
|
||||
}
|
||||
outRect.top = mDrawable.getIntrinsicHeight();
|
||||
outRect.bottom = 0;
|
||||
} else {
|
||||
if (!needsVerticalDecoration()) {
|
||||
return;
|
||||
}
|
||||
if (layoutManager.isLayoutRtl()) {
|
||||
outRect.right = mDrawable.getIntrinsicWidth();
|
||||
outRect.left = 0;
|
||||
} else {
|
||||
outRect.left = mDrawable.getIntrinsicWidth();
|
||||
outRect.right = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setOffsetAlongMainAxis(Rect outRect, int position,
|
||||
FlexboxLayoutManager layoutManager, List<FlexLine> flexLines, int flexDirection) {
|
||||
if (isFirstItemInLine(position, flexLines, layoutManager)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (layoutManager.isMainAxisDirectionHorizontal()) {
|
||||
if (!needsVerticalDecoration()) {
|
||||
outRect.left = 0;
|
||||
outRect.right = 0;
|
||||
return;
|
||||
}
|
||||
if (layoutManager.isLayoutRtl()) {
|
||||
outRect.right = mDrawable.getIntrinsicWidth();
|
||||
outRect.left = 0;
|
||||
} else {
|
||||
outRect.left = mDrawable.getIntrinsicWidth();
|
||||
outRect.right = 0;
|
||||
}
|
||||
} else {
|
||||
if (!needsHorizontalDecoration()) {
|
||||
outRect.top = 0;
|
||||
outRect.bottom = 0;
|
||||
return;
|
||||
}
|
||||
if (flexDirection == FlexDirection.COLUMN_REVERSE) {
|
||||
outRect.bottom = mDrawable.getIntrinsicHeight();
|
||||
outRect.top = 0;
|
||||
} else {
|
||||
outRect.top = mDrawable.getIntrinsicHeight();
|
||||
outRect.bottom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void drawVerticalDecorations(Canvas canvas, RecyclerView parent) {
|
||||
if (!needsVerticalDecoration()) {
|
||||
return;
|
||||
}
|
||||
FlexboxLayoutManager layoutManager = (FlexboxLayoutManager) parent.getLayoutManager();
|
||||
int parentTop = parent.getTop() - parent.getPaddingTop();
|
||||
int parentBottom = parent.getBottom() + parent.getPaddingBottom();
|
||||
int childCount = parent.getChildCount();
|
||||
int flexDirection = layoutManager.getFlexDirection();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = parent.getChildAt(i);
|
||||
|
||||
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child.getLayoutParams();
|
||||
|
||||
int left, right;
|
||||
if (layoutManager.isLayoutRtl()) {
|
||||
left = child.getRight() + lp.rightMargin;
|
||||
right = left + mDrawable.getIntrinsicWidth();
|
||||
} else {
|
||||
right = child.getLeft() - lp.leftMargin;
|
||||
left = right - mDrawable.getIntrinsicWidth();
|
||||
}
|
||||
|
||||
int top, bottom;
|
||||
if (layoutManager.isMainAxisDirectionHorizontal()) {
|
||||
top = child.getTop() - lp.topMargin;
|
||||
bottom = child.getBottom() + lp.bottomMargin;
|
||||
} else {
|
||||
if (flexDirection == FlexDirection.COLUMN_REVERSE) {
|
||||
bottom = child.getBottom() + lp.bottomMargin + mDrawable.getIntrinsicHeight();
|
||||
bottom = Math.min(bottom, parentBottom);
|
||||
top = child.getTop() - lp.topMargin;
|
||||
} else {
|
||||
top = child.getTop() - lp.topMargin - mDrawable.getIntrinsicHeight();
|
||||
top = Math.max(top, parentTop);
|
||||
bottom = child.getBottom() + lp.bottomMargin;
|
||||
}
|
||||
}
|
||||
|
||||
mDrawable.setBounds(left, top, right, bottom);
|
||||
mDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawHorizontalDecorations(Canvas canvas, RecyclerView parent) {
|
||||
if (!needsHorizontalDecoration()) {
|
||||
return;
|
||||
}
|
||||
FlexboxLayoutManager layoutManager = (FlexboxLayoutManager) parent.getLayoutManager();
|
||||
int flexDirection = layoutManager.getFlexDirection();
|
||||
int parentLeft = parent.getLeft() - parent.getPaddingLeft();
|
||||
int parentRight = parent.getRight() + parent.getPaddingRight();
|
||||
int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = parent.getChildAt(i);
|
||||
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child.getLayoutParams();
|
||||
|
||||
int top, bottom;
|
||||
if (flexDirection == FlexDirection.COLUMN_REVERSE) {
|
||||
top = child.getBottom() + lp.bottomMargin;
|
||||
bottom = top + mDrawable.getIntrinsicHeight();
|
||||
} else {
|
||||
bottom = child.getTop() - lp.topMargin;
|
||||
top = bottom - mDrawable.getIntrinsicHeight();
|
||||
}
|
||||
|
||||
int left, right;
|
||||
if (layoutManager.isMainAxisDirectionHorizontal()) {
|
||||
if (layoutManager.isLayoutRtl()) {
|
||||
right = child.getRight() + lp.rightMargin + mDrawable.getIntrinsicWidth();
|
||||
right = Math.min(right, parentRight);
|
||||
left = child.getLeft() - lp.leftMargin;
|
||||
} else {
|
||||
left = child.getLeft() - lp.leftMargin - mDrawable.getIntrinsicWidth();
|
||||
left = Math.max(left, parentLeft);
|
||||
right = child.getRight() + lp.rightMargin;
|
||||
}
|
||||
} else {
|
||||
left = child.getLeft() - lp.leftMargin;
|
||||
right = child.getRight() + lp.rightMargin;
|
||||
}
|
||||
mDrawable.setBounds(left, top, right, bottom);
|
||||
mDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean needsHorizontalDecoration() {
|
||||
return (mOrientation & HORIZONTAL) > 0;
|
||||
}
|
||||
|
||||
private boolean needsVerticalDecoration() {
|
||||
return (mOrientation & VERTICAL) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if the given position is the first item in a flex line.
|
||||
*/
|
||||
private boolean isFirstItemInLine(int position, List<FlexLine> flexLines,
|
||||
FlexboxLayoutManager layoutManager) {
|
||||
int flexLineIndex = layoutManager.getPositionToFlexLineIndex(position);
|
||||
if (flexLineIndex != NO_POSITION &&
|
||||
flexLineIndex < layoutManager.getFlexLinesInternal().size() &&
|
||||
layoutManager.getFlexLinesInternal().get(flexLineIndex).mFirstIndex == position) {
|
||||
return true;
|
||||
}
|
||||
if (position == 0) {
|
||||
return true;
|
||||
}
|
||||
if (flexLines.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
// Check if the position is the "lastIndex + 1" of the last line in case the FlexLine which
|
||||
// has the View, whose index is position is not included in the flexLines. (E.g. flexLines
|
||||
// is being calculated
|
||||
FlexLine lastLine = flexLines.get(flexLines.size() - 1);
|
||||
return lastLine.mLastIndex == position - 1;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user