【问题标题】:textview.getPaint() got error "android.view.InflateException: Binary XML file line #21" "Error inflating class fragment"textview.getPaint() 出现错误“android.view.InflateException: Binary XML file line #21”“错误膨胀类片段”
【发布时间】:2021-06-09 19:14:02
【问题描述】:

我是 Android 工作室的新手。我正在尝试为片段中的 TextView 设置样式,但出现错误。 “膨胀类片段时出错”“二进制 XML 文件第 21 行”。感谢您的帮助!

TextView textview= (TextView) root.findViewById(R.id.textview);
EmbossMaskFilter embossmaskfilter = new EmbossMaskFilter(new float[]{1,5,1}, // direction of the light source
                0.5f, // ambient light between 0 to 1
                10, // specular highlights
                7.5f); // blur before applying lighting);
textview.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
textview.getPaint().setMaskFilter(embossmaskfilter);

【问题讨论】:

    标签: java android android-fragments


    【解决方案1】:

    Error inflating class fragment Binary XML file line #21 表示错误在您的 XML 文件中,而不是在您的代码中。很可能当您查看第 21 行中片段的 XML-Layout-File 时,您会发现某些内容不起作用。

    【讨论】:

    • 如果答案对您有帮助,您为什么要投反对票?您应该标记为解决方案,如果您喜欢它,请点赞。
    猜你喜欢
    • 1970-01-01
    • 2015-02-24
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 2022-01-18
    • 2023-03-05
    • 1970-01-01
    相关资源
    最近更新 更多