android – 更改listSeparatorTextViewStyle中使用的行颜色

android – 更改listSeparatorTextViewStyle中使用的行颜色,第1张

概述我有以下代码 <TextView android:text="@string/hello" style="?android:attr/listSeparatorTextViewStyle" /> 我会得到以下效果. 但是,我对色线不满意.我想要这样的东西 我想要像蓝色的彩色线一样.我尝试以下自定义样式. <style name="MyOwnListS 我有以下代码
<TextVIEw            androID:text="@string/hello"             />

我会得到以下效果.

但是,我对色线不满意.我想要这样的东西

我想要像蓝色的彩色线一样.我尝试以下自定义样式.

<style name="MyOwnListSeperatorTextVIEwStyle">        <item name="androID:background">@androID:drawable/List_section_divIDer_holo_light</item>        <item name="androID:textAllCaps">true</item>    <!-- copy from Widget.TextVIEw.ListSeparator --><item name="androID:background">@androID:drawable/dark_header_dither</item>    <item name="androID:layout_wIDth">match_parent</item>    <item name="androID:layout_height">wrap_content</item>    <item name="androID:textStyle">bold</item>    <item name="androID:textcolor">?textcolorSecondary</item>    <item name="androID:textSize">14sp</item>    <item name="androID:gravity">center_vertical</item>    <item name="androID:paddingleft">8dip</item>        </style>

但是它将无法正常工作,因为我收到以下错误.

错误:错误:资源不公开. (在“androID:background”,值为“@androID:drawable / dark_header_dither”).

有想法如何更改ListSeparatorTextVIEwStyle中使用的线颜色

解决方法 我需要这样做来覆盖典型的Holo Spinner风格(我不想要下划线的项目 – 我只是想要箭头),我认为这可以用同样的方式被覆盖:

首先,你想在androID样式源中找到你要覆盖的项目.有一个令人难以置信的有用的SO答案,包含所有的样式(和覆盖他们的名字)在这里:Set Dialog theme to parent Theme in Android

我相信你的是以下一行:

<item name="ListSeparatorTextVIEwStyle">@androID:style/Widget.Holo.light.TextVIEw.ListSeparator</item>

这需要我们去寻找Widget.Holo.light.TextVIEw.ListSeparator的样式,该应用程序应该位于您自己的计算机上的某个地方!但我会很容易,只需c& p:

<style name="Widget.Holo.light.TextVIEw.ListSeparator" parent="Widget.TextVIEw.ListSeparator">    <item name="androID:background">@androID:drawable/List_section_divIDer_holo_light</item></style>

现在,你可能想要单独离开,只是看看这个背景.你会发现它是一个灰色的9patch文件,看起来像你想避免的险恶的灰线.

我们需要重写这个.我相信有很多方法可以做到这一点,但我通过定制应用程序的主题来实现.这里是themes.xml文件:

<style name="Apptheme" parent="@androID:style/theme.Holo.light.NoActionbar">    <item name="androID:ListSeparatorTextVIEwStyle">@style/MyOwnListSeperatorTextVIEwStyle</item></style><style name="MyOwnListSeperatorTextVIEwStyle" parent="Widget.TextVIEw.ListSeparator">    <item name="androID:background">@drawable/make_your_own_blue_9_patch_here</item></style>

注意我们如何使用上一个SO帖子中的ListSeparatorTextVIEwStyle?而父亲的自定义风格是Widget.TextVIEw.ListSeparator从androID的风格来源?都非常重要

现在你只需要将这个主题应用到你的应用程序,但我假设你已经有了一个主题.如果还没有,您将需要自己制作9个补丁,但我只需要查看计算机上的List_section_divIDer_holo_light.9.png文件,并使灰色部分变成蓝色,然后制作一份副本并将其放入自己的可绘图文件夹.

希望这个工作和帮助!

总结

以上是内存溢出为你收集整理的android – 更改listSeparatorTextViewStyle中使用的行颜色全部内容,希望文章能够帮你解决android – 更改listSeparatorTextViewStyle中使用的行颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1133910.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存