ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Android私密样式使用

2019-08-25 13:31:14  阅读:173  来源: 互联网

标签:android xml styles


尝试继承Widget.TextView.ListSeparator样式,但现在aapt不允许这样做:

No resource found that matches the given name
‘Widget.TextView.ListSeparator

因为谷歌把它变成了私有的.但是我如何组合两种样式:ListSeparator和margin?

风格1

<style name="settings_plain_text">
<item name="android:layout_marginTop"> 10sp </item>
<item name="android:layout_marginBottom"> 10sp </item>
<item name="android:textSize"> 18sp </item>

风格2

style="?android:attr/listSeparatorTextViewStyle"

解决方法:

我复制了这个link的答案:

Hello all. I did some investigating with the frameworks team who’s in charge of aapt.
What is happening is that some styles, like WindowTitle are not public (you won’t find them in android.R.style). You should not be extending non public resources. aapt used to let you do that but it was a bug which was fixed in platform-tools r6.

The issue is that once compiled, resources are assigned an integer. In this case your custom style is assigned an integer and its parent is referenced through the parent integer.

For the framework, only public resources are guaranteed to only have the same integer, build after build. The integer of private resources integer will change from build to build.

This means that your custom style is referencing a parent that will not be valid once installed on a device. It’ll referenced either another resources or none at all, and it won’t do what you want.

If you wish to reuse a style that is private, you should copy the content of that style into your own instead of extending it.

我发现谷歌搜索的风格是that one

<style name="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:paddingStart">8dip</item>
</style>

从那里你可以修改边距.

标签:android,xml,styles
来源: https://codeday.me/bug/20190825/1718993.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有