From 62d54553851e56f40b1a19c0551ce71ba8ab20e1 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 27 Jul 2016 07:24:11 +0300 Subject: [PATCH 1/6] add https://github.com/yamblz-native/custom-viewgroup homework realisation and check some case for it --- app/build.gradle | 2 +- app/src/main/java/ru/yandex/yamblz/App.java | 7 + .../yamblz/ui/layouts/CustomLayout.java | 97 ++++++++++ app/src/main/res/layout/fragment_content.xml | 29 ++- app/src/main/res/layout/inner_test_1.xml | 85 +++++++++ app/src/main/res/layout/inner_test_10.xml | 90 +++++++++ app/src/main/res/layout/inner_test_2.xml | 84 +++++++++ app/src/main/res/layout/inner_test_3.xml | 92 +++++++++ app/src/main/res/layout/inner_test_4.xml | 90 +++++++++ app/src/main/res/layout/inner_test_5.xml | 84 +++++++++ app/src/main/res/layout/inner_test_6.xml | 177 ++++++++++++++++++ app/src/main/res/layout/inner_test_7.xml | 87 +++++++++ app/src/main/res/layout/inner_test_8.xml | 53 ++++++ app/src/main/res/layout/inner_test_9.xml | 90 +++++++++ app/src/main/res/values/strings.xml | 2 +- dependencies.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- 17 files changed, 1060 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java create mode 100644 app/src/main/res/layout/inner_test_1.xml create mode 100644 app/src/main/res/layout/inner_test_10.xml create mode 100644 app/src/main/res/layout/inner_test_2.xml create mode 100644 app/src/main/res/layout/inner_test_3.xml create mode 100644 app/src/main/res/layout/inner_test_4.xml create mode 100644 app/src/main/res/layout/inner_test_5.xml create mode 100644 app/src/main/res/layout/inner_test_6.xml create mode 100644 app/src/main/res/layout/inner_test_7.xml create mode 100644 app/src/main/res/layout/inner_test_8.xml create mode 100644 app/src/main/res/layout/inner_test_9.xml diff --git a/app/build.gradle b/app/build.gradle index 445372a..8df280d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ android { buildToolsVersion versions.buildTools defaultConfig { - applicationId 'ru.yandex.yamblz' + applicationId 'ru.yandex.yamblz_customviewgroup' minSdkVersion versions.minSdk targetSdkVersion versions.targetSdk versionCode versions.code // Notice that you may want to use BUILD_NUMBER from CI in real project with own CI. diff --git a/app/src/main/java/ru/yandex/yamblz/App.java b/app/src/main/java/ru/yandex/yamblz/App.java index d8d1c41..2853f30 100644 --- a/app/src/main/java/ru/yandex/yamblz/App.java +++ b/app/src/main/java/ru/yandex/yamblz/App.java @@ -4,6 +4,8 @@ import android.content.Context; import android.support.annotation.NonNull; +import com.facebook.stetho.Stetho; + import ru.yandex.yamblz.developer_settings.DevMetricsProxy; import ru.yandex.yamblz.developer_settings.DeveloperSettingsModel; import timber.log.Timber; @@ -31,6 +33,11 @@ public void onCreate() { DevMetricsProxy devMetricsProxy = applicationComponent.devMetricsProxy(); devMetricsProxy.apply(); } + Stetho.initialize( + Stetho.newInitializerBuilder(this) + .enableDumpapp(Stetho.defaultDumperPluginsProvider(this)) + .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this)) + .build()); } @NonNull diff --git a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java new file mode 100644 index 0000000..3e42309 --- /dev/null +++ b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java @@ -0,0 +1,97 @@ +package ru.yandex.yamblz.ui.layouts; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; + +import java.util.ArrayList; + +public class CustomLayout extends ViewGroup { + private ArrayList mMatchParentChildren = new ArrayList<>(); + + public CustomLayout(Context context) { + this(context, null, 0); + } + + public CustomLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CustomLayout(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int totalWidth = 0; + int layoutWidth = MeasureSpec.getSize(widthMeasureSpec); + //Высота лейаута по высоте максимального элемента + int maxHeight = MeasureSpec.getSize(heightMeasureSpec); + int changedHeightMeasureSpec = heightMeasureSpec; + + //Родитель может вызвать onMeasure не единожды + mMatchParentChildren.clear(); + + + for (int i = 0; i < getChildCount(); ++i) { + View child = getChildAt(i); + + if (child == null) { + continue; + } + if (child.getVisibility() == GONE) { + continue; + } + + switch (child.getLayoutParams().width) { + case LayoutParams.MATCH_PARENT: + mMatchParentChildren.add(child); + break; + case LayoutParams.WRAP_CONTENT: + default: + measureChild(child, widthMeasureSpec, heightMeasureSpec); + totalWidth += child.getMeasuredWidth(); + int measuredHeight = child.getMeasuredHeight(); + if (maxHeight < measuredHeight) { + maxHeight = measuredHeight; + changedHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.UNSPECIFIED); + } + } + } + + //Если осталось место или оно не ограничено, почему бы не показать matchParent + if ((totalWidth < layoutWidth) || widthMeasureSpec == MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)) { + //В случае, если не знаем ширина родителя не остановленна,используем вдвое увеличенную ширину не match_parent элементов + layoutWidth = layoutWidth != 0 ? layoutWidth : totalWidth * 2; + //Остаток разделям между оставшимися детьми + int mpChildWidth = (layoutWidth - totalWidth) / mMatchParentChildren.size(); + int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(mpChildWidth, MeasureSpec.EXACTLY); + for (int i = 0; i < mMatchParentChildren.size(); i++) { + measureChild(mMatchParentChildren.get(i), childWidthMeasureSpec, changedHeightMeasureSpec); + totalWidth += mMatchParentChildren.get(i).getMeasuredWidth(); + int measuredHeight = mMatchParentChildren.get(i).getMeasuredHeight(); + if (maxHeight < measuredHeight) { + maxHeight = measuredHeight; + changedHeightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST); + } + } + } + super.onMeasure(MeasureSpec.makeMeasureSpec(layoutWidth, MeasureSpec.EXACTLY), changedHeightMeasureSpec); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + + int horizontalOffset = getPaddingLeft(); + int verticalOffset = getPaddingTop(); + int childCount = getChildCount(); + for (int i = 0; i < childCount; ++i) { + View child = getChildAt(i); + int childWidth = child.getMeasuredWidth(); + int childHeight = child.getMeasuredHeight(); + child.layout(horizontalOffset, verticalOffset, horizontalOffset + childWidth, verticalOffset + childHeight); + horizontalOffset += childWidth; + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_content.xml b/app/src/main/res/layout/fragment_content.xml index 81016ea..a32b71d 100644 --- a/app/src/main/res/layout/fragment_content.xml +++ b/app/src/main/res/layout/fragment_content.xml @@ -1,14 +1,23 @@ - + + + android:layout_height="wrap_content" + android:orientation="vertical"> - \ No newline at end of file + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_1.xml b/app/src/main/res/layout/inner_test_1.xml new file mode 100644 index 0000000..e623869 --- /dev/null +++ b/app/src/main/res/layout/inner_test_1.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_10.xml b/app/src/main/res/layout/inner_test_10.xml new file mode 100644 index 0000000..9fb5105 --- /dev/null +++ b/app/src/main/res/layout/inner_test_10.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_2.xml b/app/src/main/res/layout/inner_test_2.xml new file mode 100644 index 0000000..4abc754 --- /dev/null +++ b/app/src/main/res/layout/inner_test_2.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_3.xml b/app/src/main/res/layout/inner_test_3.xml new file mode 100644 index 0000000..89b1b46 --- /dev/null +++ b/app/src/main/res/layout/inner_test_3.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_4.xml b/app/src/main/res/layout/inner_test_4.xml new file mode 100644 index 0000000..a00f22f --- /dev/null +++ b/app/src/main/res/layout/inner_test_4.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_5.xml b/app/src/main/res/layout/inner_test_5.xml new file mode 100644 index 0000000..76a1f08 --- /dev/null +++ b/app/src/main/res/layout/inner_test_5.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_6.xml b/app/src/main/res/layout/inner_test_6.xml new file mode 100644 index 0000000..2d43e22 --- /dev/null +++ b/app/src/main/res/layout/inner_test_6.xml @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_7.xml b/app/src/main/res/layout/inner_test_7.xml new file mode 100644 index 0000000..38f6732 --- /dev/null +++ b/app/src/main/res/layout/inner_test_7.xml @@ -0,0 +1,87 @@ + + + + + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_8.xml b/app/src/main/res/layout/inner_test_8.xml new file mode 100644 index 0000000..e29bdeb --- /dev/null +++ b/app/src/main/res/layout/inner_test_8.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_test_9.xml b/app/src/main/res/layout/inner_test_9.xml new file mode 100644 index 0000000..c310426 --- /dev/null +++ b/app/src/main/res/layout/inner_test_9.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7474f04..b179ab0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - Yamblz + Custom ViewGroup Hello diff --git a/dependencies.gradle b/dependencies.gradle index d9cb375..d340e7b 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -7,7 +7,7 @@ ext.versions = [ compileSdk : 23, buildTools : '23.0.3', - androidGradlePlugin : '2.2.0-alpha4', + androidGradlePlugin : '2.2.0-alpha6', aptGradlePlugin : '1.8', retrolambdaGradlePlugin : '3.2.5', lombokGradlePlugin : '0.2.3.a2', diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 86a3e94..b8216a4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon May 30 20:17:48 ICT 2016 +#Fri Jul 22 14:49:54 MSK 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip From 3ef74f4cf13f1789c74b23a9552ed1ccee0d0151 Mon Sep 17 00:00:00 2001 From: katkalof Date: Tue, 9 Aug 2016 20:49:15 +0300 Subject: [PATCH 2/6] remove excess test --- .../main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java | 3 --- dependencies.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java index 3e42309..83acda6 100644 --- a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java +++ b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java @@ -37,9 +37,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { for (int i = 0; i < getChildCount(); ++i) { View child = getChildAt(i); - if (child == null) { - continue; - } if (child.getVisibility() == GONE) { continue; } diff --git a/dependencies.gradle b/dependencies.gradle index d340e7b..6c870d1 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -7,7 +7,7 @@ ext.versions = [ compileSdk : 23, buildTools : '23.0.3', - androidGradlePlugin : '2.2.0-alpha6', + androidGradlePlugin : '2.2.0-alpha7', aptGradlePlugin : '1.8', retrolambdaGradlePlugin : '3.2.5', lombokGradlePlugin : '0.2.3.a2', diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b8216a4..20d27fa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jul 22 14:49:54 MSK 2016 +#Tue Aug 09 20:47:38 MSK 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip From 3efbfa90cb4b032404f86e9ebe97289fdd13dae7 Mon Sep 17 00:00:00 2001 From: katkalof Date: Tue, 9 Aug 2016 21:11:49 +0300 Subject: [PATCH 3/6] add onlayout visibility==gone check --- .../main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java index 83acda6..6e01f8c 100644 --- a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java +++ b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java @@ -85,6 +85,9 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { int childCount = getChildCount(); for (int i = 0; i < childCount; ++i) { View child = getChildAt(i); + if (child.getVisibility() == GONE) { + continue; + } int childWidth = child.getMeasuredWidth(); int childHeight = child.getMeasuredHeight(); child.layout(horizontalOffset, verticalOffset, horizontalOffset + childWidth, verticalOffset + childHeight); From d666b53dc2964723cf1dd3b898d652f876448ac6 Mon Sep 17 00:00:00 2001 From: katkalof Date: Tue, 9 Aug 2016 23:35:20 +0300 Subject: [PATCH 4/6] fix wrong work with 2 and more element and layout padding, add example to confirm why - it was wrong using measureChild to element which width = match_parent how - using measure for match_parent width children and consider layout padding in onMeasure --- .../yamblz/ui/layouts/CustomLayout.java | 19 +++- app/src/main/res/layout/fragment_content.xml | 1 + app/src/main/res/layout/inner_test_3.xml | 2 + app/src/main/res/layout/inner_test_33.xml | 104 ++++++++++++++++++ 4 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/layout/inner_test_33.xml diff --git a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java index 6e01f8c..cf4bb65 100644 --- a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java +++ b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java @@ -24,10 +24,12 @@ public CustomLayout(Context context, AttributeSet attrs, int defStyleAttr) { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int horizontalPadding = getPaddingLeft() + getPaddingRight(); + int verticalPadding = getPaddingTop() + getPaddingBottom(); int totalWidth = 0; - int layoutWidth = MeasureSpec.getSize(widthMeasureSpec); + int layoutWidth = MeasureSpec.getSize(widthMeasureSpec) - horizontalPadding; //Высота лейаута по высоте максимального элемента - int maxHeight = MeasureSpec.getSize(heightMeasureSpec); + int maxHeight = MeasureSpec.getSize(heightMeasureSpec) - verticalPadding; int changedHeightMeasureSpec = heightMeasureSpec; //Родитель может вызвать onMeasure не единожды @@ -56,7 +58,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { } } } - //Если осталось место или оно не ограничено, почему бы не показать matchParent if ((totalWidth < layoutWidth) || widthMeasureSpec == MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)) { //В случае, если не знаем ширина родителя не остановленна,используем вдвое увеличенную ширину не match_parent элементов @@ -65,7 +66,15 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int mpChildWidth = (layoutWidth - totalWidth) / mMatchParentChildren.size(); int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(mpChildWidth, MeasureSpec.EXACTLY); for (int i = 0; i < mMatchParentChildren.size(); i++) { - measureChild(mMatchParentChildren.get(i), childWidthMeasureSpec, changedHeightMeasureSpec); + int childHeightMeasureSpec = getChildMeasureSpec( + heightMeasureSpec, + verticalPadding, + mMatchParentChildren.get(i).getLayoutParams().height + ); + mMatchParentChildren.get(i).measure( + childWidthMeasureSpec, + childHeightMeasureSpec + ); totalWidth += mMatchParentChildren.get(i).getMeasuredWidth(); int measuredHeight = mMatchParentChildren.get(i).getMeasuredHeight(); if (maxHeight < measuredHeight) { @@ -74,7 +83,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { } } } - super.onMeasure(MeasureSpec.makeMeasureSpec(layoutWidth, MeasureSpec.EXACTLY), changedHeightMeasureSpec); + super.onMeasure(MeasureSpec.makeMeasureSpec(layoutWidth + horizontalPadding, MeasureSpec.EXACTLY), changedHeightMeasureSpec); } @Override diff --git a/app/src/main/res/layout/fragment_content.xml b/app/src/main/res/layout/fragment_content.xml index a32b71d..02dc0a6 100644 --- a/app/src/main/res/layout/fragment_content.xml +++ b/app/src/main/res/layout/fragment_content.xml @@ -12,6 +12,7 @@ + diff --git a/app/src/main/res/layout/inner_test_3.xml b/app/src/main/res/layout/inner_test_3.xml index 89b1b46..d7f0379 100644 --- a/app/src/main/res/layout/inner_test_3.xml +++ b/app/src/main/res/layout/inner_test_3.xml @@ -12,6 +12,7 @@ @@ -52,6 +53,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From bc0416a03b8d2e95a0e90a7bd49701739be13674 Mon Sep 17 00:00:00 2001 From: katkalof Date: Wed, 10 Aug 2016 08:39:39 +0300 Subject: [PATCH 5/6] fix wrong work with 2 and more element and layout padding, add example to confirm why - it was wrong using measureChild to element which width = match_parent how - using measure for match_parent width children and consider layout padding in onMeasure --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index 6c870d1..ab031cf 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -7,7 +7,7 @@ ext.versions = [ compileSdk : 23, buildTools : '23.0.3', - androidGradlePlugin : '2.2.0-alpha7', + androidGradlePlugin : '2.2.0-beta1', aptGradlePlugin : '1.8', retrolambdaGradlePlugin : '3.2.5', lombokGradlePlugin : '0.2.3.a2', From 4f1158b74cdccd8d11a807ab04b3f77ad524f3a4 Mon Sep 17 00:00:00 2001 From: katkalof Date: Wed, 10 Aug 2016 09:10:18 +0300 Subject: [PATCH 6/6] check divide by zero exception, when not match_parent children --- .../main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java index cf4bb65..80c314c 100644 --- a/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java +++ b/app/src/main/java/ru/yandex/yamblz/ui/layouts/CustomLayout.java @@ -59,7 +59,10 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { } } //Если осталось место или оно не ограничено, почему бы не показать matchParent - if ((totalWidth < layoutWidth) || widthMeasureSpec == MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)) { + boolean haveSpace = (totalWidth < layoutWidth) + || widthMeasureSpec == MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); + //И у нас есть, чем его заполнять + if ((mMatchParentChildren.size() > 0) && haveSpace) { //В случае, если не знаем ширина родителя не остановленна,используем вдвое увеличенную ширину не match_parent элементов layoutWidth = layoutWidth != 0 ? layoutWidth : totalWidth * 2; //Остаток разделям между оставшимися детьми