Android 如何更改CardInputWidget(条带)的fontFamily

Android 如何更改CardInputWidget(条带)的fontFamily,android,stripe-payments,android-styles,android-fonts,Android,Stripe Payments,Android Styles,Android Fonts,我正在尝试将一个CardInputWidget主题设置为与我的应用程序的其余部分相匹配,但我似乎无法将android:fontFamily=“@font/font\u name”项目直接应用于视图或样式或主题 这是com.stripe:stripe android:5.1.0根据我的实验,通过android:theme属性中使用的样式设置android:fontFamily,根本不起作用 但是,我可以使用此方法在CardInputWidget中搜索所有TextView子项,并在运行时更改它们的字

我正在尝试将一个
CardInputWidget
主题设置为与我的应用程序的其余部分相匹配,但我似乎无法将
android:fontFamily=“@font/font\u name”
项目直接应用于视图或样式或主题


这是
com.stripe:stripe android:5.1.0

根据我的实验,通过
android:theme
属性中使用的样式设置
android:fontFamily
,根本不起作用

但是,我可以使用此方法在
CardInputWidget
中搜索所有
TextView
子项,并在运行时更改它们的字体:

public static void setTypeface(Typeface tf, View v) {
    if (v instanceof TextView) {
        ((TextView) v).setTypeface(tf);
    }
    else if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;

        for (int i = 0; i < vg.getChildCount(); i++) {
            setTypeface(tf, vg.getChildAt(i));
        }
    }
}

根据我的实验,通过
android:theme
属性中使用的样式设置
android:fontfamine
,根本不起作用

但是,我可以使用此方法在
CardInputWidget
中搜索所有
TextView
子项,并在运行时更改它们的字体:

public static void setTypeface(Typeface tf, View v) {
    if (v instanceof TextView) {
        ((TextView) v).setTypeface(tf);
    }
    else if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;

        for (int i = 0; i < vg.getChildCount(); i++) {
            setTypeface(tf, vg.getChildAt(i));
        }
    }
}

您可以对自定义字体使用主题属性主题。我在下面给出了代码快照

  // use this in card
         <com.stripe.android.view.CardInputWidget
            android:id="@+id/card_input_widget"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/textRegular"      <---- use this
              />


 <style name="textRegular" parent="android:Widget.TextView">
    <item name="android:fontFamily">@font/poppins_regular</item>
</style>
//在卡中使用此功能

您可以对自定义字体使用主题属性主题。我在下面给出了代码快照

  // use this in card
         <com.stripe.android.view.CardInputWidget
            android:id="@+id/card_input_widget"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/textRegular"      <---- use this
              />


 <style name="textRegular" parent="android:Widget.TextView">
    <item name="android:fontFamily">@font/poppins_regular</item>
</style>
//在卡中使用此功能

有没有办法改变提示的颜色和字体?有没有办法改变提示的颜色和字体?