将顶部两个文本视图与不同的字体大小对齐 [英] Align top two textviews with different font sizes

查看:63
本文介绍了将顶部两个文本视图与不同的字体大小对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用约束布局,我想实现以下目标:

Im using constraint layout and i want to achieve the following:

app:layout_constraintBaseline_toBaselineOf属性底部对齐两个文本视图,有什么方法可以顶部对齐两个文本视图吗?常规的app:layout_constraintTop_toTopOf当然由于大小差异而无法正常工作.

The app:layout_constraintBaseline_toBaselineOf attribute bottom aligns the two textviews, is there any way to top align the two? The regular app:layout_constraintTop_toTopOf is not working of course because of the size differences.

推荐答案

因此,似乎没有简便的方法,必须实现自定义视图.我从这里汲取了灵感:

So it seems there is no a convenient way of doing this and a custom view must be implemented. I've taken inspiration from here:

https://github.com/fabiomsr/MoneyTextView

这篇关于将顶部两个文本视图与不同的字体大小对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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