Fixed cardview resizing itself idiotically in constraint layout

This commit is contained in:
Viktor De Pasquale 2020-01-06 16:33:55 +01:00
parent c0b56b927f
commit baf18a8762

View File

@ -12,225 +12,232 @@
</data> </data>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:id="@+id/dialog_base_outside_container" android:id="@+id/dialog_base_outside_container"
android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.card.MaterialCardView <FrameLayout
style="@style/WidgetFoundation.Card.Elevated" android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardElevation="@dimen/margin_generic"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
app:cardUseCompatPadding="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHeight_default="wrap"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_default="percent" app:layout_constraintWidth_default="percent"
app:layout_constraintWidth_max="400dp" app:layout_constraintWidth_max="400dp"
app:layout_constraintWidth_percent="1"> app:layout_constraintWidth_percent="1">
<androidx.constraintlayout.widget.ConstraintLayout <com.google.android.material.card.MaterialCardView
style="@style/WidgetFoundation.Card.Elevated"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:cardElevation="@dimen/margin_generic"
app:cardUseCompatPadding="true">
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dialog_base_start" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="16dp" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/dialog_base_end" android:id="@+id/dialog_base_start"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintGuide_end="16dp" /> app:layout_constraintGuide_begin="16dp" />
<FrameLayout <androidx.constraintlayout.widget.Guideline
android:id="@+id/dialog_base_icon" android:id="@+id/dialog_base_end"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/dialog_base_title" android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintGuide_end="16dp" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView
style="@style/WidgetFoundation.Icon.Primary"
gone="@{data.icon == 0}"
srcCompat="@{data.icon}"
android:layout_gravity="center"
android:layout_marginTop="@dimen/l1"
android:padding="0dp"
tools:src="@drawable/ic_delete_md2" />
<androidx.appcompat.widget.AppCompatImageView
style="@style/WidgetFoundation.Image.Big"
gone="@{data.iconRaw == null}"
android:layout_gravity="center"
android:layout_marginTop="@dimen/l1"
android:src="@{data.iconRaw}"
tools:src="@drawable/ic_delete_md2" />
</FrameLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/dialog_base_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:gravity="center"
android:text="@{data.title}"
android:textAppearance="@style/AppearanceFoundation.Title"
app:layout_constraintEnd_toEndOf="@+id/dialog_base_end"
app:layout_constraintStart_toStartOf="@+id/dialog_base_start"
app:layout_constraintTop_toBottomOf="@+id/dialog_base_icon"
tools:lines="1"
tools:text="@tools:sample/lorem/random" />
<FrameLayout
android:id="@+id/dialog_base_scroll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l_50"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@+id/dialog_base_space"
app:layout_constraintEnd_toEndOf="@+id/dialog_base_end"
app:layout_constraintStart_toStartOf="@+id/dialog_base_start"
app:layout_constraintTop_toBottomOf="@+id/dialog_base_title">
<androidx.core.widget.NestedScrollView
gone="@{data.message.length == 0}"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/dialog_base_message"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@{data.message}"
android:textAppearance="@style/AppearanceFoundation.Body"
tools:lines="3"
tools:text="@tools:sample/lorem/random" />
</androidx.core.widget.NestedScrollView>
<FrameLayout <FrameLayout
android:id="@+id/dialog_base_container" android:id="@+id/dialog_base_icon"
gone="@{data.message.length != 0}" android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<Space
android:id="@+id/dialog_base_space"
android:layout_width="wrap_content"
android:layout_height="@dimen/l1"
app:layout_constraintBottom_toTopOf="@+id/dialog_base_buttons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<FrameLayout
android:id="@+id/dialog_base_buttons"
style="?attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.ButtonBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="bottom|center_horizontal" app:layout_constraintBottom_toTopOf="@+id/dialog_base_title"
android:layoutDirection="locale" app:layout_constraintEnd_toEndOf="parent"
android:orientation="horizontal" app:layout_constraintStart_toStartOf="parent"
android:paddingStart="12dp" app:layout_constraintTop_toTopOf="parent">
android:paddingTop="4dp"
android:paddingEnd="12dp"
android:paddingBottom="4dp">
<com.google.android.material.button.MaterialButton <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/dialog_base_button_4" style="@style/WidgetFoundation.Icon.Primary"
style="@style/WidgetFoundation.Button.Text" gone="@{data.icon == 0}"
gone="@{data.buttonIDGAF.icon == 0 &amp;&amp; data.buttonIDGAF.title.length == 0}" srcCompat="@{data.icon}"
isEnabled="@{data.buttonIDGAF.isEnabled()}" android:layout_gravity="center"
android:layout_width="wrap_content" android:layout_marginTop="@dimen/l1"
android:padding="0dp"
tools:src="@drawable/ic_delete_md2" />
<androidx.appcompat.widget.AppCompatImageView
style="@style/WidgetFoundation.Image.Big"
gone="@{data.iconRaw == null}"
android:layout_gravity="center"
android:layout_marginTop="@dimen/l1"
android:src="@{data.iconRaw}"
tools:src="@drawable/ic_delete_md2" />
</FrameLayout>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/dialog_base_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l1"
android:gravity="center"
android:text="@{data.title}"
android:textAppearance="@style/AppearanceFoundation.Title"
app:layout_constraintEnd_toEndOf="@+id/dialog_base_end"
app:layout_constraintStart_toStartOf="@+id/dialog_base_start"
app:layout_constraintTop_toBottomOf="@+id/dialog_base_icon"
tools:lines="1"
tools:text="@tools:sample/lorem/random" />
<FrameLayout
android:id="@+id/dialog_base_scroll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/l_50"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@+id/dialog_base_space"
app:layout_constraintEnd_toEndOf="@+id/dialog_base_end"
app:layout_constraintStart_toStartOf="@+id/dialog_base_start"
app:layout_constraintTop_toBottomOf="@+id/dialog_base_title">
<androidx.core.widget.NestedScrollView
gone="@{data.message.length == 0}"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/dialog_base_message"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@{data.message}"
android:textAppearance="@style/AppearanceFoundation.Body"
tools:lines="3"
tools:text="@tools:sample/lorem/random" />
</androidx.core.widget.NestedScrollView>
<FrameLayout
android:id="@+id/dialog_base_container"
gone="@{data.message.length != 0}"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<Space
android:id="@+id/dialog_base_space"
android:layout_width="wrap_content"
android:layout_height="@dimen/l1"
app:layout_constraintBottom_toTopOf="@+id/dialog_base_buttons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<FrameLayout
android:id="@+id/dialog_base_buttons"
style="?attr/buttonBarStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.ButtonBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:gravity="bottom|center_horizontal"
android:filterTouchesWhenObscured="true" android:layoutDirection="locale"
android:onClick="@{() -> data.buttonIDGAF.clicked()}" android:orientation="horizontal"
android:text="@{data.buttonIDGAF.title}" android:paddingStart="12dp"
app:icon="@{data.buttonIDGAF.icon}" android:paddingTop="4dp"
tools:icon="@drawable/ic_bug_md2" android:paddingEnd="12dp"
tools:text="Button 1" /> android:paddingBottom="4dp">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/dialog_base_button_2" android:id="@+id/dialog_base_button_4"
style="@style/WidgetFoundation.Button.Text" style="@style/WidgetFoundation.Button.Text"
gone="@{data.buttonNeutral.icon == 0 &amp;&amp; data.buttonNeutral.title.length == 0}" gone="@{data.buttonIDGAF.icon == 0 &amp;&amp; data.buttonIDGAF.title.length == 0}"
isEnabled="@{data.buttonNeutral.isEnabled()}" isEnabled="@{data.buttonIDGAF.isEnabled()}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:filterTouchesWhenObscured="true" android:filterTouchesWhenObscured="true"
android:onClick="@{() -> data.buttonNeutral.clicked()}" android:onClick="@{() -> data.buttonIDGAF.clicked()}"
android:text="@{data.buttonNeutral.title}" android:text="@{data.buttonIDGAF.title}"
app:icon="@{data.buttonNeutral.icon}" app:icon="@{data.buttonIDGAF.icon}"
app:iconGravity="textStart" tools:icon="@drawable/ic_bug_md2"
tools:icon="@drawable/ic_bug_md2" tools:text="Button 1" />
tools:text="Button 1" />
<Space <com.google.android.material.button.MaterialButton
android:id="@+id/spacer" android:id="@+id/dialog_base_button_2"
android:layout_width="0dp" style="@style/WidgetFoundation.Button.Text"
android:layout_height="0dp" gone="@{data.buttonNeutral.icon == 0 &amp;&amp; data.buttonNeutral.title.length == 0}"
android:layout_weight="1" isEnabled="@{data.buttonNeutral.isEnabled()}"
android:visibility="invisible" /> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:filterTouchesWhenObscured="true"
android:onClick="@{() -> data.buttonNeutral.clicked()}"
android:text="@{data.buttonNeutral.title}"
app:icon="@{data.buttonNeutral.icon}"
app:iconGravity="textStart"
tools:icon="@drawable/ic_bug_md2"
tools:text="Button 1" />
<com.google.android.material.button.MaterialButton <Space
android:id="@+id/dialog_base_button_3" android:id="@+id/spacer"
style="@style/WidgetFoundation.Button.Text" android:layout_width="0dp"
gone="@{data.buttonNegative.icon == 0 &amp;&amp; data.buttonNegative.title.length == 0}" android:layout_height="0dp"
isEnabled="@{data.buttonNegative.isEnabled()}" android:layout_weight="1"
android:layout_width="wrap_content" android:visibility="invisible" />
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:filterTouchesWhenObscured="true"
android:onClick="@{() -> data.buttonNegative.clicked()}"
android:text="@{data.buttonNegative.title}"
app:icon="@{data.buttonNegative.icon}"
tools:icon="@drawable/ic_bug_md2"
tools:text="Button 1" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/dialog_base_button_1" android:id="@+id/dialog_base_button_3"
style="@style/WidgetFoundation.Button.Text" style="@style/WidgetFoundation.Button.Text"
gone="@{data.buttonPositive.icon == 0 &amp;&amp; data.buttonPositive.title.length == 0}" gone="@{data.buttonNegative.icon == 0 &amp;&amp; data.buttonNegative.title.length == 0}"
isEnabled="@{data.buttonPositive.isEnabled()}" isEnabled="@{data.buttonNegative.isEnabled()}"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:filterTouchesWhenObscured="true" android:filterTouchesWhenObscured="true"
android:onClick="@{() -> data.buttonPositive.clicked()}" android:onClick="@{() -> data.buttonNegative.clicked()}"
android:text="@{data.buttonPositive.title}" android:text="@{data.buttonNegative.title}"
app:icon="@{data.buttonPositive.icon}" app:icon="@{data.buttonNegative.icon}"
app:iconGravity="textStart" tools:icon="@drawable/ic_bug_md2"
tools:icon="@drawable/ic_bug_md2" tools:text="Button 1" />
tools:text="Button 1" />
</androidx.appcompat.widget.ButtonBarLayout> <com.google.android.material.button.MaterialButton
android:id="@+id/dialog_base_button_1"
style="@style/WidgetFoundation.Button.Text"
gone="@{data.buttonPositive.icon == 0 &amp;&amp; data.buttonPositive.title.length == 0}"
isEnabled="@{data.buttonPositive.isEnabled()}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:filterTouchesWhenObscured="true"
android:onClick="@{() -> data.buttonPositive.clicked()}"
android:text="@{data.buttonPositive.title}"
app:icon="@{data.buttonPositive.icon}"
app:iconGravity="textStart"
tools:icon="@drawable/ic_bug_md2"
tools:text="Button 1" />
</FrameLayout> </androidx.appcompat.widget.ButtonBarLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </FrameLayout>
</com.google.android.material.card.MaterialCardView> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>