0

this activity uses a horizontal layout composed of six elements : a text field, two text views, three image buttons, from left to right, like so :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

<LinearLayout
    android:id="@+id/counter_horizontal_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/counter_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:hint="@string/counter_layout_edittext_hint"
        android:imeOptions="actionDone"
        android:inputType="textCapSentences"
        android:maxLines="1" />

    <TextView
        android:id="@+id/counter_value"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:textSize="30sp"
        android:minEms="3" />

    <TextView
        android:id="@+id/counter_delta"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:minEms="3"
        android:textSize="30sp" />

    <ImageButton
        android:id="@+id/counter_delete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@android:drawable/ic_menu_delete"/>

    <ImageButton
        android:id="@+id/counter_resize"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@android:drawable/ic_menu_edit"/>

    <ImageButton
        android:id="@+id/counter_undo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="@android:drawable/ic_menu_revert"/>
</LinearLayout>

<SeekBar
    android:id="@+id/counter_seek_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

The two text views show the last value of a seekbar and the current progress (while the user uses it), as a delta, for example

10 +43

if the last value was 10, and the user is currently holding the seekbar's progress on 53. It is therefore imperative that up to three characters show in a single line; however this behaviour breaks on 2 out of three devices I tested it on, with the textview becoming dual-row, and the numbers showing as :

10 +4
3

instead.

The only requirements are that the six elements show in a row, and that the two textviews allow up to three characters without becoming dual-row. The layout can change, any item's options can change. Is there an easy way to fix this? So far I tried the android:minEms="3" trick from positive outcomes for other people on S.O., but no luck.

Thanks for your attention.

pouzzler
  • 1,800
  • 2
  • 20
  • 32
  • 1
    you could set the `maxLines` property on textview to `1`. https://stackoverflow.com/questions/31762038/how-to-set-a-textview-to-display-text-in-one-line-in-android – denvercoder9 Sep 16 '19 at 06:58
  • 1
    you can also use `android:singleLine="true"` with TextView and/or EditText. – DHAVAL A. Sep 16 '19 at 07:05
  • I'll try that later today, and comment on the results. Thanks for now until bigger thanks later :) – pouzzler Sep 16 '19 at 07:22

0 Answers0