1

I am using textview.setShadowLayer(60,0,0, 0xFF303030); inside the custom adapter of my list view. My application is running properly in all the other phones at than 4.4.2 version.

At first I was unable to find what was the real cause of the problem. Then I noticed that whenever I am commenting the above line, my application is running fine in 4.4.2.

Please help me to find a solution to use the above code in all the versions or suggest any alternative for the above code.

roy mathew
  • 7,782
  • 4
  • 29
  • 40

1 Answers1

4

PedroHawk's comment helped me to find a solution to this issue.

This is how I solved the issue:

textview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
textview.setShadowLayer(60,0,0, 0xFF303030);

While adding the above code directly, caused crashing in 2.3 devices. Then I had to do it like this:

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
{
   textview.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
textview.setShadowLayer(5,0,0, 0xFF303030);

The above code made it work properly in all the versions (I have tested with 2.3.3, 4.0.4, 4.4.2).

roy mathew
  • 7,782
  • 4
  • 29
  • 40