Answer the question
In order to leave comments, you need to log in
How to solve glitch with TextView in markup?
I'm trying to fit the text of the incoming message in one line. The text can exceed the block width for it. Then I wanted to implement a behavior in which the text ends at the border of the block with a "fading" - gradually disappearing. Found this recipe:
android:fadingEdge="horizontal"
android:ellipsize="none"
android:maxLines="1"
android:fadingEdgeLength="150dp"
android:requiresFadingEdge="horizontal"
android:inputType="text"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:id="@+id/search_item"
android:paddingBottom="15dp"
android:paddingTop="15dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:clickable="true"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="@+id/user_data"
android:gravity="center_vertical"
android:elevation="0dp"
android:layout_alignParentLeft="true">
<TextView
android:text="Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/user_name"
android:paddingRight="5dp"
android:textSize="16sp"
android:textColor="@android:color/black" />
<TextView
android:text="Привет. Как дела? Чем занимаешься? Как настроение? "
android:layout_height="wrap_content"
android:id="@+id/user_message"
android:textSize="12sp"
android:textColor="@color/text_gray"
android:fadingEdge="horizontal"
android:ellipsize="none"
android:maxLines="1"
android:fadingEdgeLength="150dp"
android:requiresFadingEdge="horizontal"
android:inputType="text"
android:layout_weight="1"
android:layout_width="0dp" />
<ImageView
android:layout_width="31dp"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/btn_star"
android:id="@+id/user_favorite"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="false"
android:layout_weight="0" />
</LinearLayout>
</LinearLayout>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question