问题描述
这是XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/modal_list_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="7.5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/title_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="@string/alert_title_small"
android:textColor="@color/alert_dialog_text_color"
android:textSize="@dimen/alert_dialog_title_font_size"
android:textStyle="bold" />
</RelativeLayout>
尽管图形布局"显示的是粗体文本,但在设备上却没有.是设备的东西还是什么?
Although the Graphical Layout shows bold text, on the device it's not. Is it a device thing or what?
更新:
对于那些一直在要求有效的XML的人,此处已更新.一个简单的相对布局.这是Java代码:
For people who keeps on asking for the ful XML, here it is updated. A simple relative layout. And here is the Java Code:
this.titleTextView.setText(this.modalListState.title);
需要考虑的事情:可能是由于设备字体引起的吗?有人有Galaxy S3可以确认吗?可能是活动风格吗?这是用于整个应用程序的一个:
Things to think about: Could it be due to the device typefaces? Does anyone have Galaxy S3 to confirm? Could it be the activity style? Here is the one used for the whole app:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="TransparentActivity" >
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowFullscreen">false</item>
</style>
TransparentActivity样式用于相关活动.
The TransparentActivity style is used for the concerned activity.
推荐答案
好吧,我发现了这个问题的愚蠢答案.我在设备上使用的是自定义字体,而不是默认字体.一旦切换到默认设置,一切都会按预期进行!
Well, I found a silly answer to this problem. I was using a custom font on the device, not the default one. Once I switched to the default one, every things worked as expected!
这篇关于Android-将TextView设置为粗体不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!