Try the below code, its working :
<TextView
android:id="@+id/food_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="bottom|center_horizontal"
android:maxLines="1"
android:ellipsize="middle"
android:scrollHorizontally="true"
android:textSize="17sp"
android:textColor="@color/food_cell_text"
android:text=""Cured beef salad with rocket lettuce,cherry tomato & grana padano""/>
android:ellipsize="middle"
doesn't seem to work with multiple lines on Android 4.0 and later. you could try the following which will work, however you only have the one line. Add the following to your textview.
android:singleLine="true"
If setMaxLines(int) has been used to set two or more lines, only TextUtils.TruncateAt.END and TextUtils.TruncateAt.MARQUEE are supported (other ellipsizing types will not do anything). https://developer.android.com/reference/android/widget/TextView.html#attr_android:ellipsize
if you want to use textview with 2 lines and ellipsize=middle you can divide your text in half and to do use it
<TextView
android:id="@+id/food_item_name_first_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="bottom|center_horizontal"
android:singleLine="true"
android:ellipsize="end"
android:textSize="17sp"
android:text="Cured beef salad with rocket "/>
<TextView
android:id="@+id/food_item_name_second_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="bottom|center_horizontal"
android:singleLine="true"
android:ellipsize="start"
android:textSize="17sp"
android:text="lettuce,cherry tomato & grana padano"/>
it looks like this
Try this,
<TextView
android:id="@+id/food_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="middle"
android:layout_margin="50dp"
android:padding="5dp"
android:gravity="center"
android:maxLines="2"
android:textColor="@color/keyBagroung"
android:text="@string/Curved"/>
Try to use string in Strings.xml file, Like this
<string name="Curved">Cured beef salad with rocket lettuce,cherry tomato & grana padano</string>
because special characters are not allowed in xml file.
try this code:
<TextView
android:id="@+id/food_item_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/txt"
android:layout_below="@+id/txt"
android:layout_marginTop="64dp"
android:ellipsize="middle"
android:gravity="bottom|center_horizontal"
android:maxLines="2"
android:text="Cured beef salad with rocket lettuce,cherry tomato , grana padano"
android:textColor="#000000"
android:textSize="17sp" />
this is screenshot