- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 Android Studio 并且在我的主要 Activity 中有一个 SwitchCompat 小部件。它的默认字体系列是 sans-serif-medium,我将其更改为 quicksand_light。我还有一些 TextViews,它们的每个 fontfamily 都设置为 quicksand_light。在我的 Activity 的 xml 文件的设计选项卡上,它显示 SwitchCompat 与 TextView 一样具有 quicksand_light 字体系列,但是当我在手机或模拟器上运行它时,SwitchCompat 的字体系列是无衬线字体。我是否需要做一些额外的事情来更改字体系列,或者这是一个错误还是这只是我?
最佳答案
我没有深入探讨为什么在 xml 中定义 fontFamily
属性时它无法正常工作,但是如果您以编程方式设置字体IT WORKS/strong>.
这是一个使用数据绑定(bind)的例子。
添加以下数据绑定(bind)适配器:
@BindingAdapter("labelTypeface")
fun setLabelTypeface(view: SwitchCompat, @FontRes id: Int) {
view.typeface = ResourcesCompat.getFont(view.context, id)
}
并在您的布局中使用它:
<android.support.v7.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:labelTypeface="@{R.font.stratum}"
... />
关于android - SwitchCompat fontfamily 不会改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48140043/
我正在尝试使用 SwitchCompat,它显示在 Android Studio 的设计 View 中,但在我的 Galaxy S4(运行 5.0.1)上,它没有显示。这是相关代码: Activity
我的问题可能最好通过视觉方式提出——我想要一个 SwitchCompat切换到他们在 Android 设置应用中的样子: 这是关闭的: 这是在: 但出于某种原因,我的 SwitchCompat 开关在
我需要更改 SwitchCompat 的轨道颜色。我试过了 this ,但它对我没有用。这是我的 XML 文件的代码 这是我的 style.xml 文件 @color/red @c
使用列表和 map 数据演示开发应用程序。要在演示文稿之间切换,应使用带有图像的自定义切换,如下所示: 如何创建这样的自定义switchcompat? 最佳答案 这是一个很好的例子: ORIGINAL
昨天我切换到 Android Studio 2.2 Preview 1,我注意到所有 SwitchCompat View 周围有一些额外的线条,它们看起来变形了。 它的样式只包含宽度/高度参数和垂直中
我正在使用 android.support.v7.widget.SwitchCompat 并且遇到以下问题 我的包含 colorControlActivated 的样式不适用 使用 Android 命
我想在代码中打开或关闭 SwitchCompat 小部件。我的意思是当用户将 SwitchCompat 从 On 更改为 Off 或其他时。我想在代码中做到这一点。我该怎么做? SwitchCompa
我想为 SwitchCompat 应用自定义样式。更改打开和关闭状态的绘图和文本。我怎样才能做到这一点?我找不到任何关于如何做到这一点的例子。我在我的 styles.xml 中尝试了以下内容,但显然我
我正在尝试在我的 fragment 中使用 switchcompat。最小支持的 API 为 14,最大为 21。我正在尝试应用 Material View 来切换所有 pre lollipop an
目前我的 SwitchCompat看起来像下面的图像(顶部),但是我需要在关闭状态下有可见文本。 我将如何实现这一目标? 最佳答案 关于android - 显示以设置在 SwitchCompat
我在 RecyclerView 适配器中仅使用一个 SwitchCompat。我需要在 RecyclerView 上单击的项目的位置,并且当我使用 TextView 而不是 SwitchCompat
我在 ActionBar 中有一个 SwitchCompat 小部件。 当按下后退按钮并“重新打开”应用程序时,SwitchCompat 会丢失状态,从打开变为关闭。 我正在实现前台,但这并不能阻止
这是未经检查的样子: 并检查: checked 明显不符合设计,那么当它被选中时,我怎样才能让它看起来像未选中? 最佳答案 您可以为两个语句使用相同的颜色: switchButton.setO
在 Android 中,是否可以垂直对齐 SwitchCompat ,即将文本放在开关上方而不是开关左侧? 最佳答案 你在找这样的东西吗? 试试这个 关于android - A
我在将 Android.Support.V7.Widget.SwitchCompat 绑定(bind)到我的 View 模型时遇到了麻烦(Mvvmcross 是我正在使用的框架)我做了与在另一个对象上
我正在尝试以编程方式添加 android.support.v7.widget.SwitchCompat,但出现此错误: java.lang.NullPointerException: Attempt
我想在 Android Studio 中使用 SwitchCompat,我把它放在 build.gradle 中: compile 'com.android.support:appcompat-v7:
这是我的代码,对我不起作用。我使用来自 this 的代码示例。 XML- 和代码: mVisibilitySwitchCompat = (SwitchCompat) findViewById(R.i
我想减少 Switch 的宽度。当前解决方案在How to change the size of a Switch Widget和 How to change Width of Android's S
我在顶部有一个主要的服务开/关开关。我希望这个开关大而显眼。 如果我将 textOn 属性更改得更长一些,它在某种程度上是在做我想做的事情,但我希望这种情况发生在更短的 textOn 字符串长度上。
我是一名优秀的程序员,十分优秀!