Skip to content

Commit

Permalink
Fix icon placement for section switches
Browse files Browse the repository at this point in the history
The way View.createSkeleton() works doesn't play nicely with
ConstraintLayout as it causes constraints to be lost, thus insert a
wrapper view to keep the constraints intact.

Fixes openhab#3773

Signed-off-by: Danny Baumann <dannybaumann@web.de>
  • Loading branch information
maniac103 committed Jul 29, 2024
1 parent f23ebe4 commit 1d1e203
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions mobile/src/main/res/layout/widgetlist_sectionswitchitem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<org.openhab.habdroid.ui.widget.WidgetImageView
android:id="@+id/widgeticon"
<FrameLayout
android:id="@+id/widgeticon_container"
android:layout_width="@dimen/widgetlist_icon_size"
android:layout_height="@dimen/widgetlist_icon_size"
app:imageScalingType="scaleToFit"
app:layout_constraintEnd_toStartOf="@+id/widgetlabel"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:src="@drawable/ic_openhab_appicon_24dp" />
app:layout_constraintBottom_toBottomOf="parent">

<org.openhab.habdroid.ui.widget.WidgetImageView
android:id="@+id/widgeticon"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:imageScalingType="scaleToFit"
tools:src="@drawable/ic_openhab_appicon_24dp" />

</FrameLayout>

<TextView
android:id="@+id/widgetlabel"
Expand All @@ -28,7 +35,7 @@
android:maxLines="1"
android:textAppearance="?attr/textAppearanceBodyLarge"
android:textDirection="locale"
app:layout_constraintStart_toEndOf="@id/widgeticon"
app:layout_constraintStart_toEndOf="@id/widgeticon_container"
app:layout_constraintTop_toTopOf="parent"
tools:text="Widget label" />

Expand Down Expand Up @@ -59,7 +66,7 @@
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/widgeticon"
app:layout_constraintStart_toEndOf="@id/widgeticon_container"
app:layout_constraintTop_toBottomOf="@id/labelbarrier"
app:singleSelection="true">

Expand Down

0 comments on commit 1d1e203

Please sign in to comment.