diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java index cb039cb6..89ed42fb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/AudioStatusDisplayItem.java @@ -92,7 +92,9 @@ public class AudioStatusDisplayItem extends StatusDisplayItem{ public void onBind(AudioStatusDisplayItem item){ int seconds=(int)item.attachment.getDuration(); String duration=formatDuration(seconds); - time.getLayoutParams().width=(int)Math.ceil(time.getPaint().measureText("-"+duration)); + // Some fonts (not Roboto) have different-width digits. 0 is supposedly the widest. + time.getLayoutParams().width=(int)Math.ceil(Math.max(time.getPaint().measureText("-"+duration), + time.getPaint().measureText("-"+duration.replaceAll("\\d", "0")))); time.setText(duration); AudioPlayerService service=AudioPlayerService.getInstance(); if(service!=null && service.getAttachmentID().equals(item.attachment.id)){ diff --git a/mastodon/src/main/res/layout/display_item_audio.xml b/mastodon/src/main/res/layout/display_item_audio.xml index 11e370b9..43053a69 100644 --- a/mastodon/src/main/res/layout/display_item_audio.xml +++ b/mastodon/src/main/res/layout/display_item_audio.xml @@ -46,6 +46,7 @@ android:textAppearance="@style/m3_label_medium" android:textColor="?colorButtonText" android:gravity="end" + android:singleLine="true" tools:text="1:23"/>