我有一个文本视图:
<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 编码还很陌生,所以我真的不知道是什么原因造成的,也不知道如何修复它。
提前致谢。