在左上角的多行的EditText到位图标 [英] Place Icon at Top Left Corner in Multiline EditText
本文介绍了在左上角的多行的EditText到位图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何图标在多行的EditText左上角,这里是我使用的:
<的EditText
机器人:ID =@ + ID / editComments
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:paddingLeft =10dp
机器人:paddingTop =10dp
机器人:paddingBottom会=20dp
机器人:paddingRight =10dp
机器人:layout_margin =10dp
机器人:提示=注释
安卓的inputType =textMultiLine
机器人:行=4
机器人:drawablePadding =20dp
安卓的minlines =4
机器人:重力=顶|左
机器人:drawableLeft =@绘制/注释
机器人:MAXLINES =4/>
我越来越图标,左对齐,但在中心不是顶部
解决方案
- 您必须了解你使用的是什么。目前是没有这样的事情的的android:setToTop 的在你EDITTEXT选择 - 这就是为什么它不对齐顶端;机器人:填充热门是<一个href=\"http://www.101apps.co.za/index.php/articles/android-s-gravity-layout-gravity-padding-and-layout-margin-attributes.html\"相对=nofollow>别的事情。
- 这要看您使用的布局 - 最好的一个了你的问题是
RelativeLayout的
,它使用的android:layout_alignTop
。
我强烈建议你阅读更多关于布局它可以帮助你了解它是如何工作以及你在做什么 - 复制和放大器;粘贴code,每次不帮助!
How Do I place icon at top left corner in multiline EditText, here is what I am using :
<EditText
android:id="@+id/editComments"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:paddingBottom="20dp"
android:paddingRight="10dp"
android:layout_margin="10dp"
android:hint="Comments"
android:inputType="textMultiLine"
android:lines="4"
android:drawablePadding="20dp"
android:minLines="4"
android:gravity="top|left"
android:drawableLeft="@drawable/comment"
android:maxLines="4" />
I am getting icon as left aligned but in center not at top
解决方案
- You have to understand what you are using. There is no such thing as android:setToTop in your editText options - that's why it does not align to the top; android:paddingTop is about something else.
- It depends on which layout are you using - the best one for your problem is
RelativeLayout
, which usesandroid:layout_alignTop
.
I strongly suggest that you should read more about layouts which can help you understand how it works and what are you doing - copy & paste the code doesn't help every time!
这篇关于在左上角的多行的EditText到位图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文