【问题标题】:Change TextStyle Programmatically以编程方式更改 TextStyle
【发布时间】:2019-04-10 13:47:53
【问题描述】:
@Override
protected void onBindViewHolder(@NonNull final Chat.MessagesViewHolder holder, final int position, @NonNull final MessagesHelper model) {
       holder.mDisplayText.setBackgroundColor(BackgoundColorSent);
}

我可以为 textColor 和 size 做到这一点,但没有 textStyle 的方法。我正在使用firebaseRecyclerAdapter 并希望根据用户的喜好以编程方式更改recyclerView 项目的style

【问题讨论】:

  • sse TextView#setTextAppearance
  • setTextAppearence() 括号内应该有什么......就像我只想要 3 种样式粗斜体和粗斜体 @pskink
  • 那为什么不使用textView.setTypeface(Typeface.DEFAULT_BOLD);
  • @MichelleKinsten 试试这个.. textView.setTextAppearance(getActivity(), R.style.fontForNotificationLandingPage);

标签: java android xml android-studio styles


【解决方案1】:

您可以使用setTypeface 将样式应用于您的文本

textView.setTypeface(Typeface.BOLD_ITALIC);

您可以使用的其他字体有:

  1. 字体.BOLD
  2. 字体.NORMAL
  3. 字体.SANS_SERIF
  4. 字体.MONOSPACE
  5. 字体.斜体

【讨论】:

    【解决方案2】:

    最好用xml文件“textStyle()”中的命令来改变texstyle

    您需要在您的 itemview 中更改布局。

    希望能帮到你。

    【讨论】:

    • 我希望用户为所有项目选择 textStyle...我如何实现这一目标
    猜你喜欢
    • 2011-12-16
    • 1970-01-01
    • 2015-08-16
    • 2012-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多