gpt4 book ai didi

android - textView : text invisible 中投影和 embossMaskFilter 之间的冲突

转载 作者:行者123 更新时间:2023-11-29 01:58:08 31 4
gpt4 key购买 nike

我有一个 TextView :

<TextView
android:id="@+id/textAfter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="example string"
android:textColor="@android:color/transparent"
android:textSize="40sp"
/>

此 textView 随后以编程方式以一系列方式进行修改:

imageView_Source = (TextView)findViewById(R.id.source);
textAfter = (TextView)findViewById(R.id.textAfter);

X_FONT = Typeface.createFromAsset(getResources().getAssets(), "ROCKB.TTF");
//textAfter = new TextView(getApplicationContext());
textAfter.setTypeface(X_FONT);
localTextPaint = textAfter.getPaint();
localTextPaint.setTextScaleX(1f);
localTextPaint.setFakeBoldText(true);
localTextPaint.setAntiAlias(true);
localTextPaint.setSubpixelText(true);
localTextPaint.setMaskFilter(new EmbossMaskFilter(new float[] { 1, 1, 1 },ambientValue, specularValue, blurRadiusValue));

public void onClick(View v) {
//textAfter.invalidate();
localTextPaint.setMaskFilter(null);
textAfter.invalidate();
localTextPaint.setMaskFilter(new EmbossMaskFilter(new float[] { 1, 1, 1 },ambientValue, specularValue, blurRadiusValue));
textAfter.invalidate();

}};

onClick 仅用于测试目的。但是,如果我添加以下内容:

 android:shadowColor="#000000"
android:shadowDx="3.0"
android:shadowDy="3.0"
android:shadowRadius="1.0"

文本变得完全不可见。虽然阴影和蒙版在单独应用时都有效,但在同时应用时都不起作用(不会出现垂直向上的文本)。我猜这也与应用于阴影的蒙版有关,但我对 Android 编码还很陌生,所以我真的不知道是什么原因造成的,也不知道如何解决。

提前致谢。

最佳答案

我遇到了同样的事情,我意识到这是由于硬件加速造成的。

要为特定 View 禁用硬件加速,请执行以下操作:

<TextView>.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

关于android - textView : text invisible 中投影和 embossMaskFilter 之间的冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14027506/

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