android-支持库版本28.0.0 TabLayout错误

android-支持库版本28.0.0 TabLayout错误,第1张

概述在更新到最新版本支持库(27.1.1->28.0.0)之后,用户界面存在问题.一个问题:理想状态:tab_layout_unselected_indicator.xml:<?xmlversion="1.0"encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apkes/android">&

在更新到最新版本的支持库(27.1.1-> 28.0.0)之后,用户界面存在问题.

一个问题:


理想状态:

tab_layout_unselected_indicator.xml:

<?xml version="1.0" enCoding="utf-8"?><@R_683_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID">    <item        androID:left="-5dp"        androID:right="-5dp"        androID:top="-5dp">        <shape>            <stroke                androID:wIDth="2dp"                androID:color="@color/colorGrey" />        </shape>    </item></@R_683_3419@>

tab_layout:

<androID.support.design.Widget.TabLayout        androID:ID="@+ID/tab_layout"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:background="@color/colorBlackDark"        androID:theme="@style/Apptheme.AppbarOverlay"        app:tabBackground="@drawable/tab_layout_unselected_indicator"        app:tabIndicatorcolor="@color/colorOrange"        app:tabMode="fixed"        app:tabSelectedTextcolor="@color/colorOrange"        app:tabTextAppearance="@style/StrikeCustomTabText"        app:tabTextcolor="@color/colorGrey" />

看起来一个标签的背景与另一个标签交叉.我试图更改缩进并注意到这一点.现在,我正在使用支持库的早期版本(27.1.1).如何为当前版本的支持库(28.0.0)修复此问题?

解决方法:

用以下内容替换背景可绘制对象:

<?xml version="1.0" enCoding="utf-8"?><@R_683_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID">    <item>        <shape androID:shape="rectangle">            <solID androID:color="@color/colorGrey"/>        </shape>    </item>    <item androID:bottom="2dp">        <shape androID:shape="rectangle">            <solID androID:color="@color/colorBlackDark"/>        </shape>    </item></@R_683_3419@>

您已正确确定当前背景的问题;新的支持库允许选项卡项目在其边界之外绘制,因此您看到的是负边距边框实际上现在出现了,而不是被剪切掉了.

要解决此问题,您可以改为绘制整个灰色背景,然后绘制大约2dp的黑色来覆盖其中的大部分.这永远不会超出选项卡项目范围,因此问题消失了.这里的透支成本很小(因为“线”色必须与“背景”色重叠),但是我认为这对三个选项卡不会有任何性能影响.

总结

以上是内存溢出为你收集整理的android-支持库版本28.0.0 TabLayout错误全部内容,希望文章能够帮你解决android-支持库版本28.0.0 TabLayout错误所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存