gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 21:10:48 28 4
gpt4 key购买 nike

我有以下布局:

<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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com