【问题标题】:Android: How to make the text size of Borderless button same as that of TextViewAndroid:如何使无边框按钮的文本大小与TextView的相同
【发布时间】:2015-01-30 09:19:07
【问题描述】:

在以下两张图中,水平线性布局中有四个小部件:

  1. TextView 和文本 Results:
  2. Borderless Button 和文本 My Cat
  3. View 是“垂直分隔符”的 hack
  4. Borderless Button 和文本 My Dog

两个问题:

  1. Results: 在第一个是粗体,因为我使用了<b> 标签 在字符串资源文件中围绕它。但我使用了<strong> 在第二个中添加标签,这不会使其变为粗体。

    did read thatstrong有语义,所以那可能是一个 盲人的屏幕阅读器会以不同的语气阅读,因为 盲人。 但在视觉上,它应该是粗体的,不是吗?

  2. 我希望Buttons 中的文本与 TextView。我相信为此我需要获取 TextView(或Android系统中的默认大小?或“默认 大小”是用户设备上的东西吗?:s)在spbecausesp 也被用户的字体偏好缩放)然后设置 按钮的文字大小一样吗?我该怎么做

我可以用 XML 做吗?还是只是可能以编程方式?以及如何?

【问题讨论】:

  • @Downvoter 请告诉我原因??

标签: android button textview text-size borderless


【解决方案1】:
Text size micro = 12sp.   
Text size small = 14sp.   
Text size medium = 18sp.   
Text size large = 22sp.   

【讨论】:

    【解决方案2】:

    使用 android:textStyle="bold" 用于粗体文本,使用 android:textSize="12sp" 更改 xml 中按钮的文本大小。

    【讨论】:

    • 谢谢解答,12spTextView的默认文字大小吗?
    • 共有三个“默认” textSize 值:14sp,18sp,22sp 这些定义如下 TextAppearances - TextAppearance.Small - TextAppearance.Medium - TextAppearance.Large
    • 再次感谢您,那么默认的 TextAppearance 是什么?这样尺寸在所有情况下都保持不变。
    • 默认为 14sp。您可以通过 float size = new Button(this).getTextSize(); 获取默认大小
    • 非常感谢,您能否在答案中也附加此信息,对将来访问的人有用。
    猜你喜欢
    • 1970-01-01
    • 2011-02-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 2013-06-26
    相关资源
    最近更新 更多