From 9ba281befb22c206ae0fbc0d2e4b82b16244f6b4 Mon Sep 17 00:00:00 2001 From: davidoskky Date: Tue, 8 Dec 2020 20:13:33 +0100 Subject: [PATCH] Position of the elements in list view fixed in place. (#314) Closes #287 --- .../adapters/ItemListAdapter.kt | 17 --------------- app/src/main/res/layout/list_item.xml | 21 ++++++++++--------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt index 0781573..7f958c0 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/adapters/ItemListAdapter.kt @@ -79,23 +79,6 @@ class ItemListAdapter( holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText() if (itm.getThumbnail(c).isEmpty()) { - val sizeInInt = 46 - val sizeInDp = TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, sizeInInt.toFloat(), c.resources - .displayMetrics - ).toInt() - - val marginInInt = 16 - val marginInDp = TypedValue.applyDimension( - TypedValue.COMPLEX_UNIT_DIP, marginInInt.toFloat(), c.resources - .displayMetrics - ).toInt() - - val params = holder.mView.itemImage.layoutParams as ViewGroup.MarginLayoutParams - params.height = sizeInDp - params.width = sizeInDp - params.setMargins(marginInDp, 0, 0, 0) - holder.mView.itemImage.layoutParams = params if (itm.getIcon(c).isEmpty()) { val color = generator.getColor(itm.sourcetitle) diff --git a/app/src/main/res/layout/list_item.xml b/app/src/main/res/layout/list_item.xml index 7415fe5..3eb339e 100644 --- a/app/src/main/res/layout/list_item.xml +++ b/app/src/main/res/layout/list_item.xml @@ -3,14 +3,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="88dp"> - + android:layout_height="88dp"> @@ -18,9 +18,9 @@ android:id="@+id/title" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:layout_marginStart="16dp" + android:layout_marginStart="8dp" android:layout_marginTop="8dp" + android:layout_marginEnd="16dp" android:ellipsize="end" android:fontFamily="sans-serif" android:gravity="start" @@ -39,16 +39,17 @@ android:id="@+id/sourceTitleAndDate" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginTop="8dp" + android:layout_marginStart="8dp" + android:layout_marginTop="66dp" android:layout_marginEnd="16dp" android:gravity="start" + android:maxLines="1" android:textAlignment="viewStart" android:textSize="14sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toEndOf="@+id/itemImage" - app:layout_constraintTop_toBottomOf="@+id/title" + app:layout_constraintTop_toTopOf="parent" tools:text="Google Actualité Il y a 5h" /> \ No newline at end of file