We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好! 现在有一种使用场景:允许edittext显示多行文本,即输入时可以换行输入,同时希望右边的删除图标紧贴输入框底线, 此时不指定android:inputType就可以换行,就像这样
android:inputType
随之而来的问题是, 现在希望右边的删除图标紧贴输入框底线,该如何实现? 我进行了尝试,将R.drawable.delete用layer-list包起来,并指定gravity
R.drawable.delete
layer-list
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <bitmap android:src="@drawable/delete" android:gravity="bottom"/> </item> </layer-list>
并在edittext 的 setDeleteIconVisible(boolean deleteVisible,boolean leftVisible) 方法中给上面的drawable setBounds()来设置宽高,
setDeleteIconVisible(boolean deleteVisible,boolean leftVisible)
private void setDeleteIconVisible(boolean deleteVisible,boolean leftVisible) { if (ic_delete != null) { ic_delete.setBounds(0, 0, ic_delete.getIntrinsicWidth(), getMeasuredHeight()); } setCompoundDrawables(leftVisible ? ic_left_click : ic_left_unclick, null, deleteVisible ? ic_delete: null, null); color = leftVisible ? lineColor_click : lineColor_unclick; setTextColor(color); invalidate(); }
此时删除图标的确会紧贴底线,但出现了新的问题,就是每输入一个字符,控件高度都在变高,getMeasuredHeight()总是在变大, 即使输入并没有换行。就像这样:
getMeasuredHeight()
然后我就不知道该怎么办了...希望能获得帮助 : )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
你好!
现在有一种使用场景:允许edittext显示多行文本,即输入时可以换行输入,同时希望右边的删除图标紧贴输入框底线, 此时不指定
android:inputType
就可以换行,就像这样随之而来的问题是, 现在希望右边的删除图标紧贴输入框底线,该如何实现?
我进行了尝试,将
R.drawable.delete
用layer-list
包起来,并指定gravity并在edittext 的
setDeleteIconVisible(boolean deleteVisible,boolean leftVisible)
方法中给上面的drawable setBounds()来设置宽高,此时删除图标的确会紧贴底线,但出现了新的问题,就是每输入一个字符,控件高度都在变高,
getMeasuredHeight()
总是在变大,即使输入并没有换行。就像这样:
然后我就不知道该怎么办了...希望能获得帮助 : )
The text was updated successfully, but these errors were encountered: