How to right-align text in an Android TextView or EditText?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 10:41:07

You should use android:gravity="right". layout_gravity is for the view (EditText) alignment against the container.

Erick

You may use android:layout_alignParentRight="true" to align the EditText's right edge to its parent's right edge. Also, if you really want to use the layout_gravity or gravity attributes, check out this article that discusses the proper use of them.

You can jst set property for edit text in property window i.e. Gravity to right or by adding code of lin e in xml file of UI : android:gravity="right"

layout_gravity means that you are specifying the layouts attribute, not the element inside. In some conditions, such as layout_width and layout_height is wrap_content, layout specifications can give what you want about the element inisde your layout, since the boundries of the layout and the element (not elements) are the same..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!