Android – how do I create a large fuzzy shadow behind textview?

I want to create a fairly large soft shadow under textview. But I can't use a large enough shadow radius because Android will crash if I set it to more than 25.0

The first picture above is from our IOS application and displays the shadow below the text according to my needs. As you can see, I can't recreate this shadow effect on Android

At present, the XML style of shadow effect is as follows:

<style name="TextViewShadowEffectSoft">
    <item name="android:shadowColor">#DD000000</item>
    <item name="android:shadowDx">0.0</item>
    <item name="android:shadowDy">0.0</item>
    <item name="android:shadowRadius">25.0</item>
</style>

Expand to autoresizetextview at creation (ancestor of textview):

 AutoResizeTextView title = (AutoResizeTextView) getActivity().getLayoutInflater().inflate(R.layout.text_shadow_soft, null);

text_ shadow_ The location of soft.xml is:

com.app.models.AutoResizeTextView
style="@style/TextViewShadowEffectSoft" />

The minimum API for my app is 19.0

Edit: set the crash log when Android: shadowradius is higher than 25.0:

05-12 13:16:20.590 10679-10781/com.app E/rsC++: RS CPP error: Blur radius out of 0-25 pixel bound
05-12 13:16:20.593 10679-10781/com.app E/rsC++: RS CPP error (masked by prevIoUs error): Allocation creation Failed
05-12 13:16:20.593 10679-10781/com.app E/rsC++: RS CPP error (masked by prevIoUs error): Allocation creation Failed
05-12 13:16:20.593 10679-10781/com.app E/rsC++: RS CPP error (masked by prevIoUs error): Blur radius out of 0-25 pixel bound

                                                      --------- beginning of crash
05-12 13:16:20.594 10679-10781/com.app A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x28 in tid 10781 (RenderThread)

Appreciate all ideas and opinions!

resolvent:

It seems that some code related to your hardware limits it. So please use software rendering and add Android: layertype = "software" in your view

Or use it in your code

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Documentation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>