In right side I used textview to display selected timezone, if user select it then alert dialog will open based on selection i am displaying the value.. Now the issue is I the timezone value is too length then it will not display look like the below image.. I have to replace it with "..." if its exceed.. If I set max length it will work for this small device.. But the text view size will change based on device width. So I am little confused how to handle this.. can you please help me to solve this issue.
<LinearLayout
android:layout_width="match_parent"
android:minHeight=“60dp”
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom=“10dp”
android:visibility="visible">
<EditText
android:id="@+id/etZipCode"
android:padding=“15dp”
android:layout_marginBottom=“10dp”
android:singleLine=true
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content"
android:maxLength=“8“
android:inputType="text"
android:imeOptions="actionNext" />
<TextView
android:padding=“15dp”
android:layout_marginBottom=“10dp”
android:singleLine=true
android:layout_width="match_parent"
android:minHeight="50dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableRight="@drawable/ic_dropdown_pin"
android:layout_marginBottom=“10dp“
android:layout_marginLeft=“5dp”/>
</LinearLayout>
Add a drawablePadding
attribute along with maxLines
and ellipsize
.
Try this,
<EditText
android:id="@+id/etZipCode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLength="8"
android:text="3445"
android:padding="15dp"
android:singleLine="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:drawableRight="@drawable/ic_dropdown_pin"
android:minHeight="50dp"
android:padding="15dp"
android:text="Alaska Standard Time"
android:ellipsize="end"
android:maxLines="1"
android:drawablePadding="10dp"
android:singleLine="true"/>
</LinearLayout>
Screenshot below,
The suggested solutions with
android:ellipsize="end"
android:maxLines="1"
are correct, but lacks of an important detail. You are applying to your TextView a compound Drawable on the right.. to make the three dots appear in this scenario, you have to apply a android:drawablePadding="{something}dp"
attribute to the TextView as well.
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With