Skip to content

Commit 8e4164d

Browse files
committed
chore(browser): stabilize scrollbar + improve truncated text UX
- Set fixed row height (56dp) in card browser to prevent scrollbar jitter - Add ellipsize/line limits and improved styling to browser columns - Add ellipsize to note type field & tag list layouts - Add long-press toast + tooltip to view full text for truncated items Adds UX hints for truncated text and preserves smooth scrolling across lists.
1 parent 53c89c0 commit 8e4164d

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/browser/BrowserMultiColumnAdapter.kt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ class BrowserMultiColumnAdapter(
246246
LayoutInflater
247247
.from(parent.context)
248248
.inflate(R.layout.card_item_browser, parent, false)
249+
// Set a fixed height to prevent scrollbar jitter, with enough space to show content
250+
val params = view.layoutParams
251+
params.height = (parent.context.resources.displayMetrics.density * 56).toInt() // 56dp for better visibility
252+
view.layoutParams = params
249253
return MultiColumnViewHolder(view)
250254
}
251255

@@ -275,7 +279,23 @@ class BrowserMultiColumnAdapter(
275279
holder.numberOfColumns = row.cellsCount
276280

277281
for (i in 0 until row.cellsCount) {
278-
holder.columnViews[i].text = renderColumn(i)
282+
val columnText = renderColumn(i)
283+
holder.columnViews[i].text = columnText
284+
// Add long-press handler to show full text when truncated
285+
holder.columnViews[i].setOnLongClickListener { view ->
286+
android.widget.Toast
287+
.makeText(
288+
context,
289+
"Long text:\n$columnText",
290+
android.widget.Toast.LENGTH_LONG,
291+
).show()
292+
true
293+
}
294+
// Set content description for accessibility and add tooltip
295+
holder.columnViews[i].contentDescription = columnText
296+
if (columnText.length > 30) {
297+
holder.columnViews[i].setTooltipText("Long press to see full text")
298+
}
279299
}
280300
holder.setIsSelected(isSelected)
281301
val rowColor =

AnkiDroid/src/main/res/layout/browser_column_cell.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@
2121
android:paddingStart="8dp"
2222
android:paddingVertical="1dp"
2323
android:layout_gravity="top"
24+
android:gravity="center_vertical|start"
25+
android:ellipsize="end"
26+
android:maxLines="2"
27+
android:textColor="?android:attr/textColorPrimary"
28+
android:textSize="14sp"
29+
android:paddingEnd="6dp"
30+
android:paddingVertical="6dp"
31+
android:lineSpacingMultiplier="1.1"
2432
/>

AnkiDroid/src/main/res/layout/card_item_browser.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:id="@+id/card_item_browser"
44
android:layout_width="match_parent"
5-
android:layout_height="wrap_content"
5+
android:layout_height="56dp"
66
android:background="?attr/selectableItemBackground"
7+
android:orientation="horizontal"
78
xmlns:tools="http://schemas.android.com/tools">
89

910
<CheckBox

AnkiDroid/src/main/res/layout/item_notetype_field.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
app:layout_constraintEnd_toStartOf="@+id/btn_actions"
2222
app:layout_constraintHorizontal_chainStyle="spread_inside"
2323
android:layout_marginEnd="4dp"
24+
android:ellipsize="end"
25+
android:singleLine="true"
2426
tools:drawableEnd="@drawable/ic_sort"
2527
tools:text="Field name" />
2628

AnkiDroid/src/main/res/layout/item_require_exclude_tag.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
android:gravity="center_vertical"
99
android:paddingHorizontal="8dp"
1010
android:background="?attr/selectableItemBackground"
11+
android:ellipsize="end"
12+
android:singleLine="true"
1113
tools:text="Tag entry"/>

AnkiDroid/src/main/res/layout/tags_item_list_dialog.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
android:layout_weight="1"
3131
android:paddingStart="6dp"
3232
android:textSize="16sp"
33+
android:ellipsize="end"
34+
android:singleLine="true"
3335
tools:text="Example Tag" />
3436

3537
<com.ichi2.ui.CheckBoxTriStates

0 commit comments

Comments
 (0)