android - 在自定义样式中未应用属性 "android:textSize"

标签 android android-layout text-size

我有以下布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingTop="10sp"
    android:paddingBottom="10sp">

    <ImageView
        android:id="@+id/newsImage"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:contentDescription="@string/hello_world"
        android:src="@drawable/ic_program_blue" />

    <RelativeLayout 
        android:id="@+id/textLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/newsImage">

        <TextView
            android:id="@+id/titleText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello_world"
            style="@style/newsListItemTitle" />
        <TextView
            android:id="@+id/shortText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/titleText"
            android:text="@string/hello_world" 
            style="@style/newsListItemShort" />

    </RelativeLayout>

</RelativeLayout>

还有这个样式定义:

<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:style/Theme.Holo.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>


    <!-- NAVIGATION DRAWER -->

    <!-- Items -->
    <style name="navDrawerItem">
        <item name="android:minHeight">48dp</item>
        <item name="android:textSize">22sp</item>
        <item name="android:textColor">#686868</item>
        <item name="android:paddingRight">40dp</item>
        <item name="android:gravity">center_vertical</item>
    </style>


    <!-- NEWS -->

    <!-- Item title -->
    <style name="newsListItemTitle">
        <item name="android:singleLine">true</item>
        <item name="android:background">#66ffffff</item>
        <item name="android:paddingTop">10dp</item>
        <item name="android:paddingLeft">5dp</item>
        <item name="android:textColor">#000000</item>
        <item name="android:textSize">23sp</item>
    </style>

    <!-- Item short -->
    <style name="newsListItemShort">
        <item name="android:singleLine">true</item>
        <item name="android:background">#66ffffff</item>
        <item name="android:paddingLeft">5dp</item>
        <item name="android:paddingBottom">10dp</item>
        <item name="android:textColor">#686868</item>
        <item name="android:textSize">15sp</item>
    </style>

</resources>

除“textSize”外,所有内容都应用于 TextView。没有文本出现在配置的 textSize 高度中。知道为什么这不起作用吗?

没有编译错误。

当我直接将属性“textSize”应用于 TextView 时,一切正常。

谢谢

最佳答案

我更正了错误的“styles.xml”文件。我有一个大于 16 的 API 样式文件。这个文件被使用了。但我编辑了标准的“styles.xml”。

关于android - 在自定义样式中未应用属性 "android:textSize",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22935909/

相关文章:

java - Socket.io 连接不适用于多个 fragment

android - 如何获取Textview中设置的字体大小

Android 主机文件使用

android - IntentService 没有启动

android - 更正 AlertDialog 中的文本颜色/外观

android - 使 Android 按钮宽度相同时出现奇怪的视觉问题

关于 XML 布局标签属性的 Android SDK 信息

android - 为什么这个安卓设备会放大文字?

android eclipse 在布局中使用字符串资源作为文本大小

Android SQLite 查询连续文本?