当前位置: 首页 > news >正文

Android输入框文字不垂直居中

最近升级了项目tagetSdk版本,发现所有EditView文字都不居中了,如下

输入区文字不在光标中间,没有垂直居中,无论怎么调整padding都不行。后来查源码,发现官方为了解决不同语言输入出现的抖动问题,默认启用了本地配置行高作为最小行高。

<!-- Whether to use the locale preferred line height for the minimum line height.This flag is useful for preventing jitter of entering letters into empty EditText.The line height of the text is determined by the font files used for drawing text in aline. However, in case of the empty text case, the line height cannot be determined andthe default line height: usually it is came from a font of Latin script. By making thisattribute to true, the TextView/EditText uses a line height that is likely used for thelocale associated with the widget. For example, if the system locale is Japanese, theheight of the EditText will be adjusted to meet the height of the Japanese font even ifthe text is empty.The default value for EditText is true if targetSdkVersion is{@link android.os.Build.VERSION_CODE#VANILLA_ICE_CREAM} or later, otherwise false.For other TextViews, the default value is false.
-->
<!-- @FlaggedApi("com.android.text.flags.fix_line_height_for_locale") -->
<attr name="useLocalePreferredLineHeightForMinimum" format="boolean" />

只需要在EditText上添加如下属性即可自定义行高了。

<AppCompatEditText ......android:useLocalePreferredLineHeightForMinimum="false"......
/>
http://www.dtcms.com/a/337918.html

相关文章:

  • Maven Shade Plugin 插件使用说明
  • 【音视频】ISP能力
  • 阿里云odps和dataworks的区别
  • 多数据源 Demo
  • 机器学习之数据预处理(二)
  • HBM CPU Cache / GPU Cache 的关系
  • 第一阶段C#-14:委托,事件
  • ubuntu 下载安装tomcat简单配置(傻瓜式教程)
  • minio安装和配置
  • JUC读写锁
  • 视觉语言导航(7)——VLN的数据集和评估方法 3.2
  • openfeign 只有接口如何创建bean的
  • C++多线程编程深度解析【C++进阶每日一学】
  • 【损失函数】完全解析(两万字解读)
  • 现有网络模型的使用及修改
  • 一般情况下,python函数都会返回对象,但有时只调用一个函数,这是在修改这个信息
  • CAG缓存增强生成与RAG检索增强生成对比
  • CAG缓存检索生成 案例流程
  • 04高级语言逻辑结构到汇编语言之逻辑结构转换 do...while 结构
  • Android Studio受难记
  • echarts实现3个y轴的图表
  • 传输层协议——TCP
  • 刺猬的开发笔记之企业级兑换奖励c端链路开发
  • 【图论 次短路】P1491 集合位置|省选-
  • 【typenum】 17 非负数标记
  • Ansible 部署LNMP
  • shell脚本实现读取ini键值
  • 部署过程 99年证书
  • Servlet上传文件
  • 亚马逊新手突围:从流量破冰到持续出单