【问题标题】:Android bypassing theme settingAndroid绕过主题设置
【发布时间】:2018-06-01 12:33:12
【问题描述】:

我在应用程序中有一个带有 TextView 的布局 - 不是我编写的。我想将其设置为粗体或更改 xml 中的字体系列。在我编写的应用程序中,它可以正常工作。但是在这一个中,变化没有显示出来。我想那是因为应用了一个主题。如果我以编程方式更改设置,它可以工作,如果我以编程方式将其设置为粗体,它可以工作。

myTextView.Typeface(Typeface.DEFAULT_BOLD)。

如何覆盖主题设置?

更新: 我的布局是这样的:

<LinearLayout
    android:id="@+id/lFiltro"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10sp"
    android:layout_marginEnd="10sp"
    android:orientation="horizontal"
    android:visibility="gone">

    <TextView
        android:id="@+id/tUno"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:fontFamily="@font/archivo_black"
        android:shadowColor="#33b5e5"
        android:shadowDx="4"
        android:shadowDy="4"
        android:shadowRadius="5"


        android:text="This is my text"
        android:textAlignment="center"
        android:textColor="#0000ff"
        android:textSize="24sp"
        android:textStyle="bold"
        android:visibility="visible" />

</LinearLayout>

【问题讨论】:

  • 您是否尝试过更改TextView 中的app:theme 属性?
  • 我的布局中没有属性“app:theme”
  • 如果您开始在 TextView 元素中输入“主题”,它应该可用。您使用的是自定义字体吗?
  • 我想使用自定义字体,但它不会改变
  • 自定义字体并不总是允许使用粗体字。

标签: android android-layout textview android-theme android-styles


【解决方案1】:

尝试添加

android:textAppearance="@style/TextAppearance.AppCompat.Subhead"

到您的 TextView xml 并根据您将获得的建议更改 TextAppearance. 之后的内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-03
    • 2012-07-31
    • 2015-03-07
    • 2018-02-14
    相关资源
    最近更新 更多