Reputation: 2518
EDIT: With the suggested answer i get this result: History layout has a listview that has a height to match parent and i think this creates some problems, is there any workaround to this? The new code that shows History layout hidden is this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:padding="@dimen/ParentLayoutPadding"
android:background="@color/BackgroundColor"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/Layout_Main">
<ScrollView
android:id="@+id/SearchNumbersScrollView"
android:fadeScrollbars="false"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/HistoryLinearLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
android:layout_height="0dp"
android:animateLayoutChanges="true">
<LinearLayout
android:id="@+id/SearchNumbersLinearLayout"
android:elevation="@dimen/ParentLayoutElevation"
android:background="@drawable/ResourceOptionsBorderWithoutTopPadding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical"
android:visibility="visible">
<RelativeLayout
android:animateLayoutChanges="true"
android:id="@+id/SearchNumbersTitleRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
style="@style/MyCategoryTitleTextStyle"
android:text="@string/Menu_DrawSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/PaidDescriptionTextView"
android:layout_centerInParent="true" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/ShowInstructionsImageButton"
android:layout_alignParentRight="true"
android:layout_width="@dimen/MinimumItemSize"
android:layout_height="@dimen/MinimumItemSize"
android:backgroundTint="@color/normalTextColorPrimaryDark"
android:background="@drawable/ic_info_layer"
android:layout_centerVertical="true"
android:contentDescription="@string/Common_InformationIconContentDescription" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_marginBottom="@dimen/LineMargin"
android:layout_height="@dimen/CategoryLineHeight"
android:background="@android:color/darker_gray"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_gravity="center">
<include
android:animateLayoutChanges="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/SelectDateRange"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
style="@style/MyTextStyle"
android:padding="@dimen/CategoryTitlePadding"
android:gravity="left"
android:text="@string/NumbersSearch_NumbersTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ListNameTextView" />
<TextView
style="@style/MyTextStyle"
android:inputType="textMultiLine"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:id="@+id/ListTextView"
android:layout_marginRight="@dimen/CategoryTitlePadding"
android:layout_alignBottom="@+id/ListNameTextView"
android:layout_alignBaseline="@+id/ListNameTextView"
android:hint="@string/NumbersSearch_NumbersHint"
android:gravity="left"
android:ellipsize="end"
android:minLines="1"
android:maxLines="2" />
<com.google.android.material.button.MaterialButton
style="@style/AppTheme.GrayButtonStyle"
android:text="@string/NumbersSearch_NumberSelectionButtonTitle"
android:layout_marginRight="@dimen/CategoryTitlePadding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/OptionsTextView"
android:id="@+id/SelectNumbersButton"
android:layout_centerHorizontal="true" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical"
android:layout_gravity="left">
<CheckBox
style="@style/MyTextStyle"
android:text="@string/NumbersSearch_SearchPerNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/CheckboxMarginTopBottom"
android:layout_marginBottom="@dimen/CheckboxMarginTopBottom"
android:id="@+id/SeperateCheckBox"
android:buttonTint="@color/buttonColorPrimary"
android:paddingRight="@dimen/CheckBoxPadding" />
<CheckBox
style="@style/MyTextStyle"
android:text="@string/NumbersSearch_IncludeDrawTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/CheckboxMarginTopBottom"
android:layout_marginBottom="@dimen/CheckboxMarginTopBottom"
android:id="@+id/ShowListsCheckBox"
android:buttonTint="@color/buttonColorPrimary"
android:paddingRight="@dimen/CheckBoxPadding" />
<LinearLayout
android:id="@+id/SearchTypeLinearLayout"
android:layout_below="@+id/SelectDate"
android:paddingLeft="@dimen/CategoryTitlePadding"
android:paddingRight="@dimen/CategoryTitlePadding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:layout_weight="1"
style="@style/MyTextStyle"
android:text="@string/NumbersSearch_ShowResultsTitle"
android:inputType="textMultiLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ShowResultsTitleTextView"
android:minLines="1"
android:maxLines="2"
android:gravity="left" />
<Spinner
android:id="@+id/ShowResultsSpinner"
android:layout_toRightOf="@+id/ShowResultsTitleTextView"
android:layout_below="@+id/SelectDate"
android:ellipsize = "none"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:foregroundGravity="center_vertical"
android:layout_alignBottom="@+id/ShowResultsTitleTextView"
android:paddingLeft="@dimen/SpinnerPaddingStartEnd"
android:paddingStart="@dimen/SpinnerPaddingTopBottom"
android:paddingBottom="@dimen/SpinnerPaddingTopBottom"
android:paddingTop="@dimen/SpinnerPaddingTopBottom"
android:layout_alignTop="@+id/ShowResultsTitleTextView" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<com.google.android.material.button.MaterialButton
style="@style/AppTheme.ButtonStyle"
android:elevation="@dimen/ButtonElevation"
android:text="@string/NumbersSearch_ButtonSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/OptionsTextView"
android:id="@+id/SearchButton"
android:gravity="center"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true" />
</LinearLayout>
</ScrollView>
<include
android:id="@+id/HistoryLinearLayout"
app:layout_constraintTop_toBottomOf="@+id/SearchNumbersScrollView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:minHeight="150dp"
layout="@layout/HistoryLinearLayout"/>
</androidx.constraintlayout.widget.ConstraintLayout>
HistoryLinearLayout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:minHeight="@dimen/MinimumHistoryLayoutHeight"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/HistoryLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/HistoryPadding"
android:gravity="center"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:id="@+id/HistoryTitleTextView"
style="@style/MyTextStyle"
android:text="@string/Common_HistoryWithColon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/ParentLayoutPadding"
android:gravity="center"
android:layout_centerHorizontal="true" />
<com.google.android.material.button.MaterialButton
style="@style/AppTheme.GrayButtonStyle"
android:text="@string/NumbersSearch_Clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/OptionsTextView"
android:id="@+id/ClearHistoryButton"
android:layout_centerHorizontal="true" />
</LinearLayout>
<ListView
android:id="@+id/HistoryListView"
android:background="@drawable/ListViewBackground"
android:layout_below="@id/HistoryLinearLayout"
android:clipToPadding="false"
android:clipChildren="false"
android:divider="@color/BackgroundColor"
android:dividerHeight="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Dimens.xml
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<!-- common dimens -->
<dimen name="small_50">4dp</dimen>
<dimen name="small_100">8dp</dimen>
<!-- 50% of normal = 8dp -->
<dimen name="normal_100">16dp</dimen>
<!-- 100% of normal = 16dp -->
<dimen name="normal_125">20dp</dimen>
<!-- 125% of normal = 16dp + 4dp = 20dp -->
<dimen name="normal_150">24dp</dimen>
<dimen name="normal_175">28dp</dimen>
<dimen name="normal_200">32dp</dimen>
<!-- normal_200 = 2 x normal_100 -->
<dimen name="normal_225">36dp</dimen>
<dimen name="normal_250">40dp</dimen>
<dimen name="normal_275">44dp</dimen>
<dimen name="normal_300">48dp</dimen>
<!-- normal_300 = 3 x normal_100 -->
<dimen name="normal_325">52dp</dimen>
<dimen name="normal_350">56dp</dimen>
<dimen name="normal_375">60dp</dimen>
<dimen name="large_100">32dp</dimen>
<!-- large_100 = 2 x normal_100 -->
<dimen name="large_125">40dp</dimen>
<dimen name="large_150">48dp</dimen>
<dimen name="large_175">56dp</dimen>
<dimen name="large_200">64dp</dimen>
<!-- ResourceLayout -->
<dimen name="ImageViewResourceLayout">60dp</dimen>
<dimen name="ImageViewResourceLayoutPadding">7dp</dimen>
<dimen name="ResourceOptionsMarginInsideCards">4dp</dimen>
<dimen name="ResourceOptionsMarginBetweenCards">12dp</dimen>
<dimen name="ResourceOptionsButtonOrSwitchMargin">5dp</dimen>
<dimen name="ResourceOptionsMarginBetweenLinearLayouts">10dp</dimen>
<dimen name="ResourceOptionsMarginFromScreen">12dp</dimen>
<dimen name="ResourceOptionsTextSize">14dp</dimen>
<dimen name="LineHeight">2dp</dimen>
<dimen name="CategoryLineHeight">1dp</dimen>
<dimen name="LineMarginTopBottom">10dp</dimen>
<!-- OptionsLayout -->
<dimen name="OptionsSwitchPadding">11dp</dimen>
<dimen name="RestorePurchasePadding">11dp</dimen>
<dimen name="AutoCloseEditextWidth">60dp</dimen>
<dimen name="CurrentColorSize">36dp</dimen>
<dimen name="ResourceOptionsLineMarginForCategory">60dp</dimen>
<dimen name="TemplatesSpinnerHeight">112dp</dimen>
<!-- SearchScreenLayout -->
<dimen name="ImageButtonMargin">10dp</dimen>
<dimen name="StatisticsHeight">60dp</dimen>
<dimen name="ElementPaddingTopBottom">10dp</dimen>
<dimen name="ElementPaddingParentBottom">15dp</dimen>
<dimen name="SwitchPadding">11dp</dimen>
<dimen name="SearchMargin">11dp</dimen>
<dimen name="NumbersFrequencySpinnerPadding">5dp</dimen>
<dimen name="NumberSelectionPaddingTop">10dp</dimen>
<dimen name="NumberSelectionPaddingPadding">1dp</dimen>
<dimen name="NumberSelectionSize">30dp</dimen>
<dimen name="NumberSelectionCornerRadius">15dp</dimen>
<dimen name="NumberSelectionPaddingRight">4dp</dimen>
<!-- OptionsLayout -->
<dimen name="PortMargin">8dp</dimen>
<!-- StatisticsLayout -->
<dimen name="OptionsSpinnerWidth">170dp</dimen>
<dimen name="EditTextMargin">4dp</dimen>
<dimen name="PasswordEditTextMargin">8dp</dimen>
<!-- StatisticsLayout PerformanceTrend-->
<dimen name="PerformanceScoreSize">160dp</dimen>
<dimen name="PerformanceTrendHeight">200dp</dimen>
<item format="float" name="LabelTextSize" type="dimen">40</item>
<item format="float" name="LineSize" type="dimen">10</item>
<item format="float" name="MaxValue" type="dimen">100</item>
<!-- Common -->
<dimen name="SpinnerHeight">40dp</dimen>
<dimen name="MinimumHistoryLayoutHeight">150dp</dimen>
<dimen name="HistoryPadding">4dp</dimen>
<dimen name="IconSize">24dp</dimen>
<dimen name="ButtonIconSize">20dp</dimen>
<dimen name="ParentLayoutPadding">10dp</dimen>
<dimen name="AlertDialogPadding">12dp</dimen>
<dimen name="SpinnerPaddingStartEnd">8dp</dimen>
<dimen name="SpinnerPaddingTopBottom">8dp</dimen>
<dimen name="CategoryTitlePadding">5dp</dimen>
<dimen name="CheckboxMarginTopBottom">3dp</dimen>
<dimen name="CategoryMarginTop">2dp</dimen>
<dimen name="CategoryMarginBottom">5dp</dimen>
<dimen name="CategoryMarginTopBottom">5dp</dimen>
<dimen name="CategorySeperatorMarginTopBottom">12dp</dimen>
<dimen name="SelectDateMarginRight">5dp</dimen>
<dimen name="ParentLayoutElevation">1dp</dimen>
<dimen name="ButtonMargin">5dp</dimen>
<dimen name="ButtonElevation">2dp</dimen>
<dimen name="TwoLineText">2</dimen>
<dimen name="UnlockDateRangeMargin">12dp</dimen>
<dimen name="IconButtonSize">24dp</dimen>
<dimen name="IconButtonMargin">14dp</dimen>
<!-- OddEvenDelays -->
<dimen name="CheckBoxPadding">8dp</dimen>
<dimen name="BetPerRawWidth">50dp</dimen>
<!-- Info -->
<dimen name="ProbabilityMargin">5dp</dimen>
<dimen name="PercentageTopMargin">10dp</dimen>
<dimen name="SpinnerWidth">130dp</dimen>
</resources>
ListViewBackground.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="3dp"/>
<stroke android:width="1dp" android:color="@color/lightBackgroundColor" />
ResourceOptionsBorderWithoutTopPadding.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="3dp"/>
<padding android:left="8dp" android:right="8dp" android:bottom="8dp"/>
<stroke android:width="1dp" android:color="@color/lightBackgroundColor" />
<solid android:color="@color/lightBackgroundColor" />
</shape>
<solid android:color="@color/lightBackgroundColor" />
</shape>
styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NumberPicker" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:editTextColor">@android:color/white</item>
<item name="colorPrimary">@android:color/white</item>
<item name="colorPrimaryDark">@android:color/white</item>
<item name="colorAccent">@android:color/white</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:spinnerItemStyle">@style/spinnerItemStyle</item>
<item name="android:spinnerDropDownItemStyle">@style/spinnerDropDownItemStyle</item>
</style>
<style name="DatePickerDialogTheme" parent="ThemeOverlay.AppCompat.Dialog">
<item name="colorAccent">@color/colorPrimary</item> <!--header background-->
<item name="android:windowBackground">@color/lightBackgroundColor</item> <!--calendar background-->
<item name="android:colorControlActivated">@color/colorPrimary</item> <!--selected day-->
<item name="android:textColorPrimary">@color/colorPrimary</item> <!--days of the month-->
<item name="android:textColorSecondary">@color/colorPrimary</item> <!--days of the week-->
</style>
<style name="AppTheme.ButtonStyle" parent ="Widget.AppCompat.Button.Colored">
<!-- Widget.AppCompat.Button.Colored -->
<item name="android:textColor">@android:color/white</item>
<item name="android:backgroundTint">@color/buttonColorPrimary</item>
<item name="cornerRadius">3dp</item>
</style>
<style name="AppTheme.OutlinedButtonStyle" parent ="Widget.MaterialComponents.Button.OutlinedButton">
<!-- Widget.AppCompat.Button.Colored -->
<item name="iconPadding">0dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:insetBottom">0dp</item>
<item name="android:paddingLeft">12dp</item>
<item name="android:paddingRight">12dp</item>
<item name="android:minWidth">48dp</item>
<item name="android:minHeight">48dp</item>
<item name="android:textColor">@drawable/WhiteTextColorSelector</item>
<item name="backgroundTint">@android:color/transparent</item>
<!-- <item name="cornerRadius">3dp</item> -->
</style>
<style name="AppTheme.GrayButtonStyle" parent ="Widget.AppCompat.Button.Borderless">
<!-- Widget.AppCompat.Button.Borderless -->
<item name="android:textColor">@drawable/BasicTextColorSelector</item>
<item name="backgroundTint">@android:color/transparent</item>
<item name="cornerRadius">3dp</item>
<item name="rippleColor">@color/buttonColorPrimaryLight</item>
<item name="strokeColor">@color/buttonColorPrimaryLight</item>
<item name="strokeWidth">2dp</item>
</style>
<style name="AppTheme.WhiteButtonStyle" parent ="Widget.AppCompat.Button.Borderless">
<!-- Widget.AppCompat.Button.Borderless -->
<item name="android:textColor">@drawable/WhiteTextColorSelector</item>
<item name="backgroundTint">@android:color/transparent</item>
<item name="cornerRadius">3dp</item>
<item name="rippleColor">@android:color/white</item>
<item name="strokeColor">@android:color/white</item>
<item name="strokeWidth">2dp</item>
</style>
<style name="AppTheme.IconButtonStyle" parent ="Widget.AppCompat.Button.Borderless">
<!-- Widget.AppCompat.Button.Borderless -->
<item name="android:textColor">@color/buttonColorPrimary</item>
<item name="backgroundTint">@android:color/transparent</item>
<item name="cornerRadius">3dp</item>
<item name="rippleColor">@color/buttonColorPrimaryLight</item>
<item name="strokeColor">@color/buttonColorPrimaryLight</item>
<item name="strokeWidth">2dp</item>
</style>
<style name="NumberSelectionAlertDialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="android:windowMinWidthMajor">100%</item>
<item name="android:windowMinWidthMinor">100%</item>
<item name="android:colorAccent">@android:color/white</item>
<item name="android:windowBackground">@color/buttonColorPrimaryLight</item>
</style>
<style name="CommonAlertDialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:colorAccent">@android:color/white</item>
<item name="android:windowBackground">@color/buttonColorPrimaryLight</item>
</style>
<style name="CommonAlertDialogSpinner" parent="Widget.AppCompat.Light.DropDownItem.Spinner">
<item name="android:paddingStart">10dp</item>
<item name="android:paddingEnd">10dp</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:spinnerItemStyle">@style/spinnerCommonAlertDialogItemStyle</item>
</style>
<style name="MyTextStyle" parent="@android:style/TextAppearance.Small">
<item name="android:textColor">@drawable/BasicTextColorSelector</item>
<item name="android:buttonTint">@color/normalTextColorPrimaryDark</item>
<item name="android:textColorHint">@color/buttonColorPrimary</item>
</style>
<style name="MyCategoryTitleTextStyle" parent="MyTextStyle">
<item name="android:textStyle">bold</item>
</style>
<style name="CommonAlertDialogTextStyle" parent="@android:style/TextAppearance.Small">
<item name="android:textColor">@android:color/white</item>
</style>
<!-- Spinner style -->
<style name="spinnerCommonAlertDialogItemStyle">
<item name="android:textColor">@android:color/white</item>
<item name="android:textColorPrimary">@android:color/white</item>
</style>
<!-- Spinner style drop down style-->
<style name="spinnerCommonAlertDialogDropDownItemStyle">
<item name="android:textColor">@android:color/white</item>
</style>
<!-- Spinner style -->
<style name="spinnerItemStyle">
<item name="android:textColor">@color/colorPrimaryDark</item>
<!-- <item name="android:gravity">left</item>-->
<!-- <item name="android:textAlignment">left</item>-->
</style>
<!-- Spinner style drop down style-->
<style name="spinnerDropDownItemStyle">
<item name="android:paddingStart">@dimen/SpinnerPaddingStartEnd</item>
<item name="android:paddingEnd">@dimen/SpinnerPaddingStartEnd</item>
<item name="android:textColor">@color/colorPrimaryDark</item>
<item name="android:gravity">center</item>
<item name="android:textAlignment">center</item>
</style>
<style name="CategoryTitleTextStyle" parent="@android:style/TextAppearance.Medium" >
<item name="android:textStyle">normal</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark" />
</resources>
which looks like this in phones with 1080p resolution:
My problem is this: the blue box from the image (HistoryLinearLayout) is smaller screens appears too small, i would like to have a minimum height of 150sp ( i have try to add minHeight in the HistoryLinearLayout but it doesnt do anything) and the yellow section from the image to be scrollable when that happen, so if the yellow section doesnt fit and at the same time the HistoryLinearLayout to be at least 150sp, the yellow section to appear with scrollbar.
Right now it doesnt work, the scroll bar doesnt do anything and the minHeight is not being respected.
So in other words what i want is this: if blue section (HistoryLinearLayout) is less than 150sp, make it 150sp and make the yellow section (ScrollView) scrollable. i dont mind if this can be happen by code also.
Upvotes: 3
Views: 163
Reputation: 1459
Constraint let you build flexible layout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ScrollView
android:id="@+id/scroll"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="#aa3"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/blue"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<TextView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
android:textSize="24dp"
/>
</ScrollView>
<FrameLayout
android:id="@+id/blue"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#33f"
android:minHeight="150dp"
app:layout_constraintTop_toBottomOf="@id/scroll"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<TextView
android:layout_width="30dp"
android:layout_height="wrap_content"
android:text="bbb"
android:textSize="24dp"
/>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
If you set both scroll and blue to layout_height="0dp"
, they always share even space.
Upvotes: 1