Android:以编程方式在 EditText 中居中文本 [英] Android: Center text inside EditText programmatically

查看:26
本文介绍了Android:以编程方式在 EditText 中居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将输入的文本放在 EditText 字段中?更具体地说,光标不应从框的左侧开始,而应从中心开始,并随着输入内容的填充而向左向外移动.

Is there any way to center the inputted text in an EditText field? More specifically, instead of the cursor starting at the left of the box, it should start in the center and move outward towards the left as it is populated with inputs.

推荐答案

你应该使用

 textView.setGravity(Gravity.CENTER_HORIZONTAL);

这篇关于Android:以编程方式在 EditText 中居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆