android - 在textview末尾显示三个点

标签 android textview

在右侧我使用 textview 显示选定的时区,如果用户选择它然后警报对话框将根据选择打开我正在显示的值..现在的问题是我的时区值太长然后它不会显示外观像下面的图片..如果超过了我必须用“...”替换它..如果我设置最大长度它将适用于这个小设备..但是 TextView 大小会改 rebase 于设备宽度。所以我有点困惑如何处理这个问题..你能帮我解决这个问题吗?

<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>

最佳答案

添加 drawablePadding 属性以及 maxLinesellipsize

试试这个,

    <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

关于android - 在textview末尾显示三个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41997108/

相关文章:

java - 不幸的是应用程序停止了: AdMob Error?

android - 使用 HttpURLConnection 发布包含其他表单数据的文件

android - 在小部件上动态更改 TextView 填充

android - 从 Camera 捕获导致 Failure delivery result ResultInfo

android - Android Geofences 是否保持 Activity 状态直到删除/过期或仅直到我的 PendingIntent 启动

java - Robolectric 和 Mockito 监视 Android Activity

android - 在 TextView 中显示图像

android - 自动调整 TextView - 我可以忽略意外的名称前缀警告吗?

android - 不需要的 textview 的位图轮廓

android - 将文本保留在 TextView 中,drawableLeft 居中