在右侧我使用 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
属性以及 maxLines
和 ellipsize
。
试试这个,
<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>
截图如下,
关于android - 在textview末尾显示三个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41997108/