我想在一行中设置我的AutocompleteTextView的提示,并用点(...)截断额外的字符串。最后。
我使用的是singleLine="true"、maxLines="1"、ellipsize="end"。
但是,提示仍然显示在两行中。尽管文本设置为单行。但我需要的提示应该也需要在单行中显示。Android Studio中的预览在一行中显示了提示。但当我在设备上运行它时,它在2行代码中显示。(S5,Nexus-5,Nexus-6,J7)。
我还希望imeOption应该总是搜索。即imeOptions="actionSearch",因此我不能将其更改为actionNext。
下面是我的XML代码:
<RelativeLayout
android:id="@+id/liLaySearchMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingLeft="10dp"
android:background="@color/cococo"
android:paddingRight="10dp">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/five_dp"
android:background="@color/white"
android:padding="@dimen/two_dp"
android:scrollHorizontally="true"
android:drawablePadding="@dimen/two_dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textSize="@dimen/twelve_sp"
android:drawableLeft="@drawable/ic_action_search"
android:inputType="text"
android:hint="A Very Long Hint Text Which Need To Be Tuncated At the End In Single Line"
android:id="@+id/edSearch"
android:imeOptions="actionSearch"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/tvCancel"
/>
<TextView
android:id="@+id/tvCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_margin="@dimen/five_dp"
android:text="@string/cancel"
android:textSize="@dimen/twelve_sp"
android:textColor="@color/tw__composer_red"
android:padding="@dimen/five_dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
</RelativeLayout>有没有人能把我面临的问题说清楚?因为我想我已经使用了所有可能的解决方案,但提示仍然不在一行中。
发布于 2016-08-29 17:36:22


这些是我设备上的屏幕截图,我尝试过的xml如下
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@color/white"
android:padding="2dp"
android:scrollHorizontally="true"
android:drawablePadding="2dp"
android:singleLine="true"
android:lines="1"
android:maxLines="1"
android:ellipsize="end"
android:textSize="16sp"
android:inputType="text"
android:drawableLeft="@mipmap/ic_launcher"
android:hint="A Very Long Hint Text Which Need To Be Tuncated At the End In Single Line"
android:id="@+id/edSearch"
android:imeOptions="actionSearch"/>试着在我用过的AutoCompleteTextView上设置android:inputType="text"
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:inputType="text"
android:ellipsize="end"
android:imeOptions="actionNext"
android:hint="this is to check if it's getting truncated and in single line or not"/>发布于 2018-02-02 02:51:53
在AutoCompleteTextView上设置android:inputType="text"它对我有效,与android:ellipsize="end"不同的是,文本没有留在'...‘最终,但它确实达到了预期。
发布于 2021-08-19 07:22:42
android:completionThreshold="1"https://stackoverflow.com/questions/39202709
复制相似问题