Android EditText 中的垂直内容对齐
我有一个多行 EditText
:
<EditText
android:layout_gravity="center"
android:id="@+id/txtMessage"
android:layout_height="wrap_content"
android:layout_below="@+id/lblMessage"
android:layout_width="wrap_content"
android:width="250dip"
android:text=""
android:maxLength="760"
android:lines="4">
</EditText>
现在内容与中间对齐。我想让内容与顶部对齐。
有财产可以做到这一点吗?
I have a multi-line EditText
:
<EditText
android:layout_gravity="center"
android:id="@+id/txtMessage"
android:layout_height="wrap_content"
android:layout_below="@+id/lblMessage"
android:layout_width="wrap_content"
android:width="250dip"
android:text=""
android:maxLength="760"
android:lines="4">
</EditText>
Now the content is aligned to the middle. And I'd like to have the content aligned to the top.
Is there a property to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
android:gravity="top"
因此
android:gravity="top"
将文本设置在“顶部”位置。您还可以设置不同的
android:gravity
属性值,例如center
、bottom
、center_vertical
、< code>left、right
、center_horizontal
等尽情享受!
Try this:
android:gravity="top"
so
android:gravity="top"
sets the text at the "Top" Position.You can also set different
android:gravity
attribute value such ascenter
,bottom
,center_vertical
,left
,right
,center_horizontal
, etc.Enjoy !!
尝试
Try